-
-
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
[lifecycleExperimental] Issue #1303 #1319
[lifecycleExperimental] Issue #1303 #1319
Conversation
- `options.lifecycleExperimental`: (`Boolean` [optional]): If set to true, the entire lifecycle | ||
(`componentDidMount` and `componentDidUpdate`) of the React component is called. The current default value | ||
is `false` with enzyme v2, but the next major version will flip the default value to `true`. | ||
[`setProps`](ShallowWrapper/setProps.md) and [`setContext`](ShallowWrapper/setContext.md). Default to `false`. |
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.
I removed lifecycleExperimental mentions but perhaps you want to add some info related to the fact that now shallow has this behavior by default.
}); | ||
}); | ||
}); | ||
|
||
context('mounting phase', () => { |
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.
I guess this is not needed anymore.
'componentDidUpdate', | ||
{ foo: 'props' }, { foo: 'props' }, | ||
{ foo: 'bar' }, { foo: 'baz' }, | ||
undefined, |
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.
I do not have enough insight into enzyme to evaluate whether this is acceptable, it smells bad. I wanted to create this PR anyway so you can guide me on how this should behave and fix it (or not), the code provoking this is in ShallowWrapper.js:413. If this is as weird to you as to me, I can give it more time and research how the adapter works, that option is undefined for React16.
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.
This will be fixed at #1261
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.
Will revert this change then.
@@ -402,7 +391,7 @@ class ShallowWrapper { | |||
instance.setState(state, callback); | |||
if ( | |||
shouldRender && | |||
this[OPTIONS].lifecycleExperimental && | |||
!this[OPTIONS].disableLifecycleMethods && |
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.
This change could be the cause for the undefined in the context, my comment above. But it makes sense at first sight.
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.
This will be fixed at #1261
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.
Seems reasonable to me!
Please rebase this tho, so there's no merge commits :-)
I'm actually not sure about the code change; it might make this a semver-major. Perhaps it'd be better to remove it from the docs, but leave it in the API? |
…React 16 block to contributing doc Fixes #1303.
Agree, it'd be a breaking change, updating only the docs now. |
Removes lifecycleExperimental from ShallowWrapper docs.
Updates code throwing an error when this option is used.Updates related unit tests.Updates CONTRIBUTING doc.