-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support getDerivedStateFromError #2036
Support getDerivedStateFromError #2036
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is great!
Could we also add a test (to both shallow and mount) that has both gDSFE and cDC, and asserts on their relative orderings?
packages/enzyme-adapter-react-16.1/src/ReactSixteenOneAdapter.js
Outdated
Show resolved
Hide resolved
packages/enzyme-adapter-react-16.1/src/ReactSixteenOneAdapter.js
Outdated
Show resolved
Hide resolved
Thanks for the feedback! I'll apply the changes/resolve conversations today evening or on Friday (UTC+1). |
OK, so the tests revealed that simulateError does not cause an error boundary failure which can be triggered via real error during render. |
@barmac can you elaborate on that last comment? (also, i fixed your use of |
Thanks for the I updated PR so that we actually pass the type to simulate error instead of relying on constructor property. The previous comment is irrelevant as I forgot that with |
I'm not sure that's necessarily true; you could easily have a rendering error without corrupting the state. |
packages/enzyme-adapter-react-16.1/src/ReactSixteenOneAdapter.js
Outdated
Show resolved
Hide resolved
packages/enzyme-adapter-react-16.1/src/ReactSixteenOneAdapter.js
Outdated
Show resolved
Hide resolved
Rolled back react-adapter-16.1-3 changes as |
Updated branch. @ljharb please check whether it's ready to be merged :). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, almost there :-)
I've made a few of the changes, and rebased; some tests are failing locally. |
Thanks :) I ran |
Looks like react v16.8.3 fails, and v16.8.4 passes. I'll update master with a broader test matrix, and rebase this PR. |
Still same, |
hmm, interesting. maybe it's the test renderer? I'll check again. |
k, now i can't reproduce :-) i'll rebase this, and once tests pass, merge. Thanks for your patience! |
- [new] `Utils` add `findElement`, `getNodeFromRootFinder`, `wrapWithWrappingComponent`, `getWrappingComponentMountRenderer`; add `RootFinder` (#1966) - [new] add `getDerivedStateFromError` support (#2036) - [fix] `shallow`/`mount`: `renderProp`: avoid warning when render prop returns `null` (#2076) - [build] include source maps - [deps] update `eslint` - [dev deps] update `eslint`, `semver`, `rimraf`, `react-is`, `html-element-map`, `chai`, `eslint-plugin-mocha`
- [new] Add support for wrapping `Profiler` (#2055) - [new] support shallow rendering `createContext()` providers and consumers - add `isContextConsumer`, `getProviderFromConsumer` (#1966) - [new] add `wrapWithWrappingComponent`, `isCustomComponent` (#1960) - [new] add `getDerivedStateFromError` support (#2036) - [fix] avoid invariant violation in provider (#2083) - [fix] properly fix finding memo(SFC) components (#2081) - [fix] properly render memoized SFCs - [fix] `shallow`: avoid wrapping component for hooks - [deps] update `react-is` - [dev deps] update `eslint` - [refactor] use `react-is` predicates more - [build] include source maps
This PR adds support for
static getDerivedStateFromError
.