Skip to content
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

Merged
merged 1 commit into from
Nov 4, 2017
Merged

[lifecycleExperimental] Issue #1303 #1319

merged 1 commit into from
Nov 4, 2017

Conversation

maurocarrero
Copy link
Contributor

@maurocarrero maurocarrero commented Nov 3, 2017

Removes lifecycleExperimental from ShallowWrapper docs.
Updates code throwing an error when this option is used.
Updates related unit tests.
Updates CONTRIBUTING doc.

- `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`.
Copy link
Contributor Author

@maurocarrero maurocarrero Nov 3, 2017

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', () => {
Copy link
Contributor Author

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,
Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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 &&
Copy link
Contributor Author

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.

Copy link
Contributor

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

@maurocarrero maurocarrero changed the title [lifecycleExperimental] [lifecycleExperimental] Issue #1303 Nov 3, 2017
Copy link
Member

@ljharb ljharb left a 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 :-)

@ljharb
Copy link
Member

ljharb commented Nov 4, 2017

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?

@maurocarrero
Copy link
Contributor Author

Agree, it'd be a breaking change, updating only the docs now.
As it is now those who try to use it (because they already knew the flag), could receive misleading errors and no-op behaviour.
I'd be glad to help further.

@ljharb ljharb removed semver: major Breaking changes semver: patch labels Nov 4, 2017
@ljharb ljharb merged commit e435194 into enzymejs:master Nov 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants