Add tests for '@reach/utils' and compatibility check with react 18#960
Open
Add tests for '@reach/utils' and compatibility check with react 18#960
Conversation
…al/test instead of @testing-library/react
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 9af9a61:
|
dartess
commented
Aug 25, 2022
| ); | ||
| lastActiveElement.current = ownerDocument.activeElement; | ||
| if ( | ||
| when === "focus" && |
Contributor
Author
There was a problem hiding this comment.
If do not check it and try use this hook with blur, handleChange will never be called, because ownerDocument.activeElement will be always ownerDocument.body.
dartess
commented
Aug 25, 2022
|
|
||
| return () => { | ||
| ownerDocument.removeEventListener(when, onChange); | ||
| ownerDocument.removeEventListener(when, onChange, true); |
Contributor
Author
There was a problem hiding this comment.
removing the handler didn't work before.
demo: https://codepen.io/dartess/pen/rNdgWEj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hi.
I covered all the hooks with tests, except for
useIsomorphicLayoutEffect(I have no idea what and how to honestly test there). I don’t see the point in covering individual helpers within this task with tests, mostly they are too simple and/or do not rely to React.In some hooks, I found problems that I fixed:
useFocusChangethat commented below;useLazyRef- unnecessarily usedany;useUpdateEffect- the cleanup return from the effect was missed, the effects were not cleaned.I also checked the work of all tests in
StrictMode(includingreact@18). One of the hooks required a rewrite - this isuseUpdateEffect. Now it works as intended.