[#77] Finally drop use of findDOMNode() #710
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #77
Fixes #704
For the longest time, since before I took over, we were filtering
specified containers through
ReactDOM.findDOMNode()
, but why?The configured trap containers (via the
containerElements
prop)must be elements already, which means they must already be rendered,
which means there's no point in passing them through
findDOMNode()
to find an underlying DOM element because they aren't React elements
in the first place.
The removal of this call should mean that React Strict Mode will
finally be OK with focus-trap-react.
Note it's still possible to render a focus trap with a single React
element child. That works fine, and never needed
findDOMNode()
anyway. We were already using a callback ref to get its element
to then auto-configure that element as the single container for
the focus trap.
Just to be sure, however, this will be released as a new major
version.
PR Checklist
Please leave this checklist in your PR.
typeof document/window !== 'undefined'
before using it in code that gets executed on load.yarn changeset
locally to add one, and follow the prompts).