Support getDerivedStateFromError#2036
Support getDerivedStateFromError#2036ljharb merged 3 commits intoenzymejs:masterfrom barmac:support-get-derived-state-from-error
Conversation
ljharb
left a comment
There was a problem hiding this comment.
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 :). |
|
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.