Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

focus-trap-react

focus-trap3.7mMIT11.0.3TypeScript support: included

A React component that traps focus.

react, reactjs, react-component, aria, accessibility, modal, dialog, focus, keyboard

readme

focus-trap-react CI Codecov license

All Contributors

A React component that traps focus.

This component is a light wrapper around focus-trap, tailored to your React-specific needs.

You might want it for, say, building an accessible modal?

What it does

Check out the demo.

Please read the focus-trap documentation to understand what a focus trap is, what happens when a focus trap is activated, and what happens when one is deactivated.

This module simply provides a React component that creates and manages a focus trap.

  • The focus trap automatically activates when mounted (by default, though this can be changed).
  • The focus trap automatically deactivates when unmounted.
  • The focus trap can be activated and deactivated, paused and unpaused via props.

Installation

npm install focus-trap-react

dist/focus-trap-react.js is the Babel-compiled file that you'll use.

React dependency

React >= 18.0.0

Note that while React 18.x still supported propTypes and defaultProps, they had long-since been deprecated, and are completely dropped in React 19.

Therefore, this library no longer assigns these properties to the <FocusTrap> element for runtime validation and initialization. The same techniques you would now use in React 19 are backward-compatible with React 18:

  • Use TypeScript for static prop type validation
  • Use a runtime validation library such as RTV.js, JSON Schema, or yup for runtime prop validation to replace prop-types)

This library aims to support one major version of React behind the current major version, since React major releases are typically years apart -- to the extent that the feature drift is not too great and remains reasonably surmountable.

Browser Support

Focused on desktop browsers, particularly Chrome, Edge, FireFox, Safari, and Opera.

Gated by what React supports in the version currently supported.

Focus-trap-react is not officially tested on any mobile browsers or devices.

⚠️ Microsoft no longer supports any version of IE, so IE is no longer supported by this library.

💬 Focus-trap-react relies on focus-trap so its browser support is at least what focus-trap supports.

💬 Keep in mind that performance optimization and old browser support are often at odds, so tabbable may not always be able to use the most optimal (typically modern) APIs in all cases.

Usage

You wrap any element that you want to act as a focus trap with the <FocusTrap> component. <FocusTrap> expects exactly one child element which can be any HTML element or other React component that contains focusable elements. It cannot be a Fragment because <FocusTrap> needs to be able to get a reference to the underlying HTML element, and Fragments do not have any representation in the DOM.

For example:

<FocusTrap>
  <div id="modal-dialog" className="modal" >
    <button>Ok</button>
    <button>Cancel</button>
  </div>
</FocusTrap>
<FocusTrap>
  <ModalDialog okButtonText="Ok" cancelButtonText="Cancel" />
</FocusTrap>

You can read further code examples in demo/ (it's very simple), and see how it works.

Here's one more simple example:

import React from 'react';
import { createRoot } from 'react-dom/client';
import { FocusTrap } from 'focus-trap-react';

class Demo extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      activeTrap: false
    };

    this.mountTrap = this.mountTrap.bind(this);
    this.unmountTrap = this.unmountTrap.bind(this);
  }

  mountTrap = () => {
    this.setState({ activeTrap: true });
  };

  unmountTrap = () => {
    this.setState({ activeTrap: false });
  };

  render() {
    const trap = this.state.activeTrap
      ? <FocusTrap
          focusTrapOptions={{
            onDeactivate: this.unmountTrap
          }}
        >
          <div className="trap">
            <p>
              Here is a focus trap
              {' '}
              <a href="#">with</a>
              {' '}
              <a href="#">some</a>
              {' '}
              <a href="#">focusable</a>
              {' '}
              parts.
            </p>
            <p>
              <button onClick={this.unmountTrap}>
                deactivate trap
              </button>
            </p>
          </div>
        </FocusTrap>
      : false;

    return (
      <div>
        <p>
          <button onClick={this.mountTrap}>
            activate trap
          </button>
        </p>
        {trap}
      </div>
    );
  }
}

createRoot(document.getElementById('root')).render(<Demo />); // React 18

❗️❗️ React 18 Strict Mode ❗️❗️

React 18 introduced new behavior in Strict Mode whereby it mimics a possible future behavior where React might optimize an app's performance by unmounting certain components that aren't in use and later remounting them with previous, reused state when the user needs them again. What constitutes "not in use" and "needs them again" is as yet undefined.

Remounted with reused state is the key difference between what is otherwise expected about unmounted components.

v9.0.2 adds support for this new Strict Mode behavior: The trap attempts to detect that it has been remounted with previous state: If the active prop's value is true, and an internal focus trap instance already exists, the focus trap is re-activated on remount in order to reconcile stated expectations.

🚨 In Strict Mode (and so in dev builds only, since this behavior of Strict Mode only affects dev builds), the trap will be deactivated as soon as it is mounted, and then reactivated again, almost immediately, because React will immediately unmount and remount the trap as soon as it's rendered.

Therefore, avoid using options like onActivate, onPostActivate, onDeactivate, or onPostDeactivate to affect component state.

<summary>Explanation and sample anti-pattern to avoid</summary>

See this discussion for an example sandbox (issue description) where onDeactivate was used to trigger the close of a dialog when the trap was deactivated (e.g. to react to the user clicking outside the trap with focusTrapOptions.clickOutsideDeactivates=true).

The result can be that (depending on how you render the trap) in Strict Mode, the dialog never appears because it gets closed as soon as the trap renders, since the trap is deactivated as soon as it's unmounted, and so the onDeactivate handler is called, thus hiding the dialog...

This is intentional: If the trap gets unmounted, it has no idea if it's being unmounted for good or if it's going to be remounted at some future point in time. It also has no idea of knowing how long it will be until it's remounted again. So it must be deactivated as though it's going away for good in order to prevent unintentional behavior and memory leaks (from orphaned document event listeners).

Props

children

⚠️ The <FocusTrap> component requires a single child, and this child must forward refs onto the element which will ultimately be considered the trap's container. Since React does not provide for a way to forward refs to class-based components, this means the child must be a functional component that uses the React.forwardRef() API.

If you must use a class-based component as the trap's container, then you will need to get your own ref to it upon render, and use the containerElements prop (initially set to an empty array []) in order to provide the ref's element to it once updated by React (hint: use a callback ref).

💬 The child is ignored (but still rendered) if the containerElements prop is used to imperatively provide trap container elements.

Example:

import { forwardRef, Component } from 'react';
import { createRoot } from 'react-dom/client';
import { FocusTrap } from 'focus-trap-react';

const container = document.getElementById('demo-function-child');

const TrapChild = forwardRef(function ({ onDeactivate }, ref) {
  return (
    <div ref={ref}>
      <p>
        Here is a focus trap <a href="#">with</a> <a href="#">some</a>{' '}
        <a href="#">focusable</a> parts.
      </p>
      <p>
        <button
          onClick={onDeactivate}
          aria-describedby="class-child-heading"
        >
          deactivate trap
        </button>
      </p>
    </div>
  );
});

TrapChild.displayName = 'TrapChild';
TrapChild.propTypes = {
  onDeactivate: propTypes.func,
};

class DemoFunctionChild extends Component {
  constructor(props) {
    super(props);

    this.state = {
      activeTrap: false,
    };

    this.mountTrap = this.mountTrap.bind(this);
    this.unmountTrap = this.unmountTrap.bind(this);
  }

  mountTrap() {
    this.setState({ activeTrap: true });
  }

  unmountTrap() {
    this.setState({ activeTrap: false });
  }

  render() {
    const trap = this.state.activeTrap && (
      <FocusTrap
        focusTrapOptions={{
          onDeactivate: this.unmountTrap,
        }}
      >
        <TrapChild />
      </FocusTrap>
    );

    return (
      <div>
        <p>
          <button onClick={this.mountTrap} aria-describedby="function-child-heading">
            activate trap
          </button>
        </p>
        {trap}
      </div>
    );
  }
}

const root = createRoot(container);
root.render(<DemoFunctionChild />);

focusTrapOptions

Type: Object, optional

Pass any of the options available in focus-trap's createOptions.

❗️ This prop is only read once on the first render. It's never looked at again. This is particularly important if you use state-dependent memoized React Hooks (e.g. const onActivate = useCallback(() => {...}, [something])) for any of the focus-trap callbacks like onActivate(), onDeactivate(), clickOutsideDeactivates(), etc.

If you need state-dependent callbacks, you have two options: (1) Use a React component class (as in the examples in this README) with bound member handlers, or (2) use a React Ref like useRef({ myState: 1 }) in your callbacks and manually manage your state.

See #947 for more details.

⚠️ See notes about testing in JSDom (e.g. using Jest) if that's what you currently use.

active

Type: Boolean, optional

By default, the FocusTrap activates when it mounts. So you activate and deactivate it via mounting and unmounting. If, however, you want to keep the FocusTrap mounted while still toggling its activation state, you can do that with this prop.

See demo/demo-special-element.js.

paused

Type: Boolean, optional

If you would like to pause or unpause the focus trap (see focus-trap's documentation), toggle this prop.

containerElements

Type: Array of HTMLElement, optional

If specified, these elements will be used as the boundaries for the focus-trap, instead of the child. These get passed as arguments to focus-trap's updateContainerElements() method.

💬 Note that when you use containerElements, the need for a child is eliminated as the child is always ignored (though still rendered) when the prop is specified, even if this prop is [] (an empty array).

Also note that if the refs you're putting into the array, like containerElements={[ref1.current, ref2.current]}, aren't resolved yet, resulting in [null, null] for example, the trap will not get created. The array must contain at least one valid HTMLElement in order for the trap to get created/updated.

If containerElements is subsequently updated (i.e. after the trap has been created) to an empty array (or an array of falsy values like [null, null]), the trap will still be active, but the TAB key will do nothing because the trap will not contain any tabbable groups of nodes. At this point, the trap can either be deactivated manually or by unmounting, or an updated set of elements can be given to containerElements to resume use of the TAB key.

Using containerElements does require the use of React refs which, by nature, will require at least one state update in order to get the resolved elements into the prop, resulting in at least one additional render. In the normal case, this is likely more than acceptable, but if you really want to optimize things, then you could consider using focus-trap directly (see Trap2.js).

Help

Testing in JSDom

⚠️ JSDom is not officially supported. Your mileage may vary, and tests may break from one release to the next (even a patch or minor release).

This topic is just here to help with what we know may affect your tests.

In general, a focus trap is best tested in a full browser environment such as Cypress, Playwright, or Nightwatch where a full DOM is available.

Sometimes, that's not entirely desirable, and depending on what you're testing, you may be able to get away with using JSDom (e.g. via Jest), but you'll have to configure your traps using the focusTrapOptions.tabbableOptions.displayCheck: 'none' option.

See Testing focus-trap in JSDom for more details.

Contributing

See CONTRIBUTING.

Contributors

In alphabetical order:

Alex Dawson
Alex Dawson

📖
Benjamin Koltes
Benjamin Koltes

🐛
Benjamin Tan
Benjamin Tan

📖
Clint Goodman
Clint Goodman

💻 📖 💡 ⚠️
Daniel
Daniel

🚧 ⚠️
Daniel Tonon
Daniel Tonon

📖 💻 ⚠️
David Clark
David Clark

💻 🐛 🚇 ⚠️ 📖 🚧
Dependabot
Dependabot

🚧
Jens Vercammen
Jens Vercammen

🐛
Johannes Ewald
Johannes Ewald

💻
Jonathan Suzuki
Jonathan Suzuki

🐛
Kasper Garnæs
Kasper Garnæs

🐛
Kathleen McMahon
Kathleen McMahon

🚧
LoganDark
LoganDark

🐛
Marais Rossouw
Marais Rossouw

🚇
Mathias Stang
Mathias Stang

🐛 👀
Michael
Michael

💡
Misha Moroshko
Misha Moroshko

🐛
Nate Liu
Nate Liu

⚠️
Rivaldo Junior
Rivaldo Junior

🚧
Scott Rippey
Scott Rippey

💻 🐛
Sean McPherson
Sean McPherson

💻
Shane Moore
Shane Moore

📦
Slapbox
Slapbox

📖 🐛
Stefan Cameron
Stefan Cameron

💻 🐛 🚇 ⚠️ 📖 🚧
Tyler Hawkins
Tyler Hawkins

📖 💡 ⚠️ 🔧
Wandrille Verlut
Wandrille Verlut

💻 ⚠️
krikienoid
krikienoid

🐛
robert-westenberger
robert-westenberger

📖 🐛
syntactic-salt
syntactic-salt

🐛

changelog

Changelog

11.0.3

Patch Changes

  • 095b3d4: Bump focus-trap dependency to v7.6.4 to get fix to manually-paused traps (see focus-trap|1340 for more info)

11.0.2

Patch Changes

  • e766841: Fix deprecation warning in React 19 when accessing ref the pre-v19 way

11.0.1

Patch Changes

  • cd75caa: Fix missing default export in typings; props no longer extend React.AllHTMLAttributes<any> to allow things like className (those extra props have always been ignored anyway); deprecate default export; add named export in code (#1396)

11.0.0

Major Changes

  • 4a37dae: Dropping propTypes and defaultProps no longer supported by React 19 and long deprecated in React 18 (going forward, use TypeScript for prop typings, and if necessary, a runtime library to validate props); Increasing minimum supported React version up to >=18; Bumping focus-trap dependency to v7.6.2

10.3.1

Patch Changes

  • ee62d91: Bump focus-trap to v7.6.1

10.3.0

Minor Changes

  • 1738674: Bump focus-trap dependency to 7.6.0 for customizable ESC behavior (#1346)

10.2.3

Patch Changes

  • 850a5a0: Bump focus-trap to v7.5.4 for shadow DOM related bug fix

10.2.2

Patch Changes

  • 10dc372: Bump focus-trap to 7.5.3 for typings fix

10.2.1

Patch Changes

  • 1d58209: Bump focus-trap to v7.5.2 for Safari-related bug fix with Array.findLast()

10.2.0

Minor Changes

  • e42bf28: Bump focus-trap to v7.5.1 for new positive tab index support in single-container traps

10.1.4

Patch Changes

  • c1d6324: Bump focus-trap to v7.4.3 for bug fix for (#962)

10.1.3

Patch Changes

  • b137dfa: Bump focus-trap to v7.4.2 for shadow DOM-related fix

10.1.2

Patch Changes

  • ada0709: Bump focus-trap to v7.4.1 and tabbable to v6.1.2 for nwsapi patch (#986).

10.1.1

Patch Changes

  • 65c508c: Bump focus-trap to v7.4.0 for new onPost/Pause and onPost/Unpause hooks via existing focusTrapOptions prop. (#948)

10.1.0

Minor Changes

  • 6c8f714: Bump focus-trap to v7.3.1 and tabbable to v6.1.1 for bug fixes and inert support.

10.0.2

Patch Changes

  • 0c98e74: Add missing trapStack option from focus-trap 7.1.0, add new isKeyForward and isKeyBackward options from focus-trap 7.2.0, bump focus-trap to 7.2.0.

10.0.1

Patch Changes

  • c772db0: Add help for Strict Mode in README #796
  • d0de500: Bump focus-trap to 7.1.0 and tabbable to 6.0.1 for new trap features and bug fixes

10.0.0

Major Changes

  • af69c14: 🚨 Breaking: Underlying tabbable dependency has been updated to v6.0.0 and contains a breaking change related to detached nodes with its default displayCheck setting. See tabbable's changelog for more information.
    • The focus-trap dependency has also be updated to v7.0.0 but only contains the underlying tabbable changes.
    • The tabbableOptions.displayCheck prop type has been updated to include the new "legacy-full" option.
  • 018732c: 🚨 Breaking: Dropped support of IE browsers, all versions.
    • IE11 was officially retired on June 15, 2022 (6 weeks ago). There are no longer any versions of IE that are still maintained or even supported by Microsoft.
  • 018732c: Revised and clarified official browser support (still as broad and deep as reasonably possible).

Patch Changes

  • b0bbbd4: Update README with a note about the children prop stating that the trap requires a single child, and that if a component is used, it must be a functional component that forwards refs.

9.0.2

Patch Changes

  • 4d8e041: Fix an issue when running in strict mode which has React immediately unmount/remount the trap, causing it to deactivate and then have to reactivate (per existing component state) on the remount. #720

9.0.1

Patch Changes

  • 2d6cd9b: Add explicit dependency on tabbable since the source directly requires it.

9.0.0

Major Changes

  • 4a77d87: Stop using the infamous findDOMNode() on provided containerElements.
    • There seems to have been no good reason for this as this prop, if specified, is already required to be an array of HTMLElement references, which means these nodes have already been rendered (if they were once React elements). There appears to have been no remaining need for this API.
    • Furthermore, the minimum supported version of React is now 16.3 as it technically has been for a while now since that is the version that introduced callback refs, which we've been using for quite some time now (so this bump will hopefully not cause any ripples).

8.11.3

Patch Changes

  • 9947461: Bump focus-trap dependency to v6.9.4 to get typings fix.
  • 519e5a5: Fix setReturnFocus option as function not being passed node focused prior to activation.

8.11.2

Patch Changes

  • 7547d93: Bumps focus-trap to v6.9.3 to pick-up some small bug fixes from underlying tabbable.

8.11.1

Patch Changes

  • 040813a: Bumps focus-trap to v6.9.1 to pick-up a fix to tabbable in v5.3.2 regarding the displayCheck=full (default) option behavior that caused issues with detached nodes.

8.11.0

Minor Changes

  • 7495680: Bump focus-trap to v6.9.0 to get bug fixes and new features to help fix some bugs.

Patch Changes

  • 7495680: Fix onDeactivate, onPostDeactivate, and checkCanReturnFocus options not being called consistently on deactivation.
  • 7495680: Fix focus not being allowed to remain on outside node post-deactivation when clickOutsideDeactivates is true or returns true.

8.10.0

Minor Changes

  • 659d44e: Bumps focus-trap to v6.8.1. The big new feature is opt-in Shadow DOM support in focus-trap (in tabbable), and new tabbable options exposed in a new focusTrapOptions.tabbableOptions configuration option.
    • ⚠️ This will likely break your tests if you're using JSDom (e.g. with Jest). See testing in JSDom for more info.

8.9.2

Patch Changes

  • 83e283c: Update focus-trap to v6.7.3 for bug fix related to elements with a negative tabindex.

8.9.1

Patch Changes

  • 3eb9421: Bump focus-trap to v6.7.2 for bug fix.

8.9.0

Minor Changes

  • 83097a5: Delay trap creation until it should be active. This is a change in behavior, however it should not break existing behavior. The delay now allows you to set active=false until you have the focusTrapOptions set correctly. #539

Patch Changes

  • 16d1ae1: Fix bug where global document was being accessed instead of first checking for focusTrapOptions.document option. #539

8.8.2

Patch Changes

  • 08a9449: Use preventScroll option on deactivation if returning focus.

8.8.1

Patch Changes

  • a2806a0: Fix SSR issues when accessing document object (#482)

8.8.0

Minor Changes

  • c8e46c2: Support new document option introduced in focus-trap v6.7.0 (#460)
  • 5ee587c: Bump focus-trap dependency to v6.7.1

8.7.1

Patch Changes

  • 111a27f: Update focus-trap to v6.6.1, to get tabbable at v5.2.1, to get bug fix for disabled fieldsets.

8.7.0

Minor Changes

  • 7fbe8ca: Update to support new features in `focus-trap@6.6.0includinginitialFocuswhich can now be false to prevent initial focus, andescapeDeactivates` which can now alternately be a function that returns a boolean instead of a straight boolean.

8.6.0

Minor Changes

  • 5292ae8:
    • Adding support for new focus-trap options from focus-trap v6.5.0: checkCanFocusTrap(), onPostActivate(), checkCanReturnFocus(), and onPostDeactivate().
    • Adding support (bug fix) for existing focus-trap setReturnFocus option that had thus far been ignored, with focus-trap-react always returning focus to the previously-focused element prior to activation regardless of the use of the setReturnFocus option. The option is now respected the same as it is when using focus-trap directly.

Patch Changes

  • 24704c7: Bump focus-trap dependency to 6.5.1 for bug fix to onPostDeactivate.

8.5.1

Patch Changes

  • b8d7071: Bump focus-trap dependency to 6.5.0 to get new features

8.5.0

Minor Changes

  • 6ee37fb: Bump focus-trap from 6.3.0 to 6.4.0. There should be no changes in behavior as a result of this upgrade.

8.4.2

Patch Changes

  • f9a6d1a: Throw an error if a Fragment is given as the child container (currently, it appears to work, but the trap is actually not activated because focus-trap can't find the DOM element for the Fragment "container"). (Fixes #268)

8.4.1

Patch Changes

  • a4c3105: Update PropTypes for clickOutsideDeactivates to match latest focus-trap.

8.4.0

Minor Changes

  • 8d58bc8: Bump focus-trap to v6.3.0

8.3.2

Patch Changes

  • 53fa056: Update focus-trap dependency to new patch release v6.2.2 for bug fix to multi-container traps.

8.3.1

Patch Changes

  • 5d70831: Bump focus-trap to 6.2.1 for bug fixes.

8.3.0

Minor Changes

  • c4e4837: Remove the need for a child, update typings, update docs:
    • Remove the need for a child in <FocusTrap /> when containerElements is used. The child was already being ignored anyway (when containerElements is used; if the prop is not used, then a single child is still required).
    • Update the typings related to the children prop to make it optional. Prop-types already had children as optional, however the use of React.Children.only() in all cases was still forcing the presence of a single child. That's no longer the case.
    • Add additional notes about the use of the containerElements prop in the documentation.

Patch Changes

  • 0836c6d: Fixing a bug where the focus trap may not have been set before it is unmounted #184

8.2.0

Minor Changes

8.1.1

Patch Changes

  • 925dfd2: Update the react and react-dom peer dependencies from ^16.0.0 to >=16.0.0 since this library works with React 17 as well as React 16.
  • 01653da: Fix focus not always returning to correct node after setting active prop to false. #139
  • 95f8ab6: Update focus-trap dependency from 6.1.2 to 6.1.4. Bug fixes only.

8.1.0

Minor Changes

  • 5994a8c: Bump focus-trap from 6.0.1 to 6.1.0. This new version of focus-trap provides a new delayInitialFocus flag that can be used to further customize trap behavior.

Patch Changes

  • 0562ef0: Change prepublishOnly script to prepare script so that it also runs if someone installs the package directly from the git repo (e.g. from your work in which you fixed a bug or added a feature you're waiting to get merged to master and published to NPM).

8.0.0

Major Changes

  • 513a2d3: BREAKING: Updated focus-trap dependency to new 6.0.1 release, which contains breaking changes. This update means it's also now using the latest version of tabbable, which also has breaking changes. See respective CHANGELOGs for details.

Patch Changes

  • 35040fa: Remove call for maintainers. @stefcameron and @maraisr hope to take up the charge. Additional help and contributors are most welcome for anyone interested!
  • 513a2d3: Changed code formatting to use dangling commas where ES5 supports them.

7.0.1

  • Fix: PropTypes definition now supports server-side rendering. #83

7.0.0

  • Add: Prop types for <FocusTrap>.
  • Update: focus-trap dependency from 4.0.2 to 5.1.0 for the latest features/fixes it provides. #71
  • BREAKING Update: Only React 16.0+ is supported going forward. #55
  • BREAKING Update: All dependencies updated to their latest versions.
  • Fix: children's type is React.ReactNode, not React.ReactElement. #66
  • Fix: Allow mutable object refs to be used for FocusTrap child. #72
  • Fix: specifiedFocusTrapOptions.includes(optionName) statement in componentDidMount() was causing an exception because includes() is not a function defined on Object.

6.0.0

  • Update focus-trap to 4.0.2, which includes a queue of traps, so when a trap is paused because another trap activates, it will be unpaused when that other trap deactivates. If Trap A was automatically paused because Trap B activated (existing behavior), when Trap B is deactivated Trap A will be automatically unpaused (new behavior).

5.0.1

  • Fix TypeScript declarations.

5.0.0

  • BREAKING: <FocusTrap> now expects exactly one child element which can be any HTML element or other React component that contains focusable elements. The tag prop has been removed, as has support for additional props that are passed through to the tag, because it is no longer necessary: you should provide your own element, with whatever props you want, as a child of <FocusTrap>.

4.0.1

  • Fix bug that caused returnFocusOnDeactivate: true to be ignored when using the active prop to activate & deactivate the focus trap.

4.0.0

  • Update focus-trap to 3.0.0, which includes a couple of behavior changes. The key change is that focus management has been changed so that you can include tricky focusable elements like radio groups, iframes, and shadow DOM components in your trap — as long as the first and last focusable elements in the trap can still be detected by Tabbable.
    • An effect of this change is that positive tabindexes are no longer guaranteed to work as expected. You should avoid these.

3.1.4

  • Re-add TypeScript declarations.

3.1.3

  • Remove componentWillMount usage.

3.1.2

  • Fix TypeScript declarations so props are available on the imported namespace.

3.1.1

  • Fix React import in TypeScript declarations.

3.1.0

  • Add TypeScript declarations.

3.0.5

  • Prevent error in IE edge cases when the previously focused element does not have a focus() function.

3.0.4

  • Allow React v16 peer dependency.

3.0.3

  • Introduce dist/focus-trap-react.js, where src/ now compiles to, since React 15.5+ demands classes, so Babel-compilation. Which is actually a huge overhaul, though in semver it's just a patch.

3.0.2

  • Fix handling of focusTrapOptions.returnFocusOnDeactivate for React-specific kinks like autoFocus on inputs.

3.0.1

  • Upgrade focus-trap for important bug fix.

3.0.0

  • Introduce focusTrapOptions prop (and remove redundancies).
  • Upgrade to focus-trap v2.

2.1.1

  • Allow React 15 as peer dependency.

2.1.0

  • Upgrade focus-trap to add escapeDeactivates and clickOutsideDeactivates props.
  • Allow arbitrary props passed through to the element itself.

2.0.1

  • Move react to peerDependencies and remove react-dom dependency.

2.0.0

  • Upgrade to React 0.14 and its companion ReactDOM.

1.0.0

  • Initial release.