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

[enzyme-adapter-react-*, shallow] [refactor]: add “lifecycles” adapter option #1696

Merged
merged 1 commit into from
Jul 3, 2018

Conversation

ljharb
Copy link
Member

@ljharb ljharb commented Jun 29, 2018

The intention here is to make a more scalable way to indicate which lifecycle methods specific adapters support.

The getSnapshotBeforeUpdate change here is breaking, but has not yet been published.

The other changes should be both backwards and forwards compatible - in other words, a before-PR enzyme should work with an after-PR adapter, and a before-PR adapter should work with an after-PR enzyme - which makes all the versions non-major. Please check this part closely.

This will create a nice clean place for the rest of the new React 16 lifecycle methods to go.

Copy link
Contributor

@brucewpaul brucewpaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One bug listed below and I don't see a reason why it won't be back/forwards compatible.

looks good!

typeof instance.getSnapshotBeforeUpdate === 'function'
) {
const snapshot = instance.getSnapshotBeforeUpdate(prevProps, prevState);
if (typeof instance.componentDidUpdate === 'function') {
instance.componentDidUpdate(prevProps, prevState, snapshot);
}
} else if (typeof instance.componentDidUpdate === 'function') {
if (adapter.options.supportPrevContextArgumentOfComponentDidUpdate) {
if (lifecycles.componentDidUpdate.prevContext) {

This comment was marked as resolved.

This comment was marked as resolved.


return {
...lifecycles,
...(componentDidUpdate && { componentDidUpdate }),

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

@ljharb ljharb merged commit 99d1e63 into master Jul 3, 2018
@ljharb ljharb deleted the lifecycles branch July 3, 2018 18:26
ljharb added a commit that referenced this pull request Jul 9, 2018
 - [fix] call ref for a root element (#1541)
 - [fix] Allow empty strings as key props (#1524)
 - [fix] Allow empty strings as key props
 - [fix] correct the adapter class name
 - [fix] `mount`: make sure it works with native arrow functions (#1667)
 - [refactor]: add “lifecycles” adapter option (#1696)
 - [refactor] use `react-is` package
 - [deps] remove unneeded `lodash` dep; update `prop-types`, `enzyme-adapter-utils`, `object.assign`
 - [dev deps] update `babel-cli`, `babel-core`, `babel-plugin-transform-replace-object-assign`, `babel-preset-airbnb`, `chai`, `coveralls`, `eslint`, `eslint-config-airbnb`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `lerna`, `json-loader`, `karma-firefox-launcher`, `prop-types`, `lerna`, `rimraf`, `webpack`
ljharb added a commit that referenced this pull request Jul 9, 2018
 - [fix] actually invoke the setState callback (#1465, #1453)
 - [fix] add missing support for animation events (#1569)
 - [fix] call ref for a root element (#1541)
 - [fix] Allow empty strings as key props (#1524)
 - [fix] correct the adapter class name
 - [fix] `mount`: make sure it works with native arrow functions (#1667)
 - [refactor]: add “lifecycles” adapter option (#1696)
 - [refactor] use `react-is` package
 - [deps] remove unneeded `lodash` dep; update `prop-types`, `enzyme-adapter-utils`, `object.assign`
 - [dev deps] update `babel-cli`, `babel-core`, `babel-plugin-transform-replace-object-assign`, `babel-preset-airbnb`, `chai`, `coveralls`, `eslint`, `eslint-config-airbnb`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `lerna`, `json-loader`, `karma-firefox-launcher`, `prop-types`, `lerna`, `rimraf`, `webpack`
ljharb added a commit that referenced this pull request Jul 9, 2018
 - [fix] actually invoke the setState callback (#1465, #1453)
 - [fix] add missing support for animation events (#1569)
 - [fix] call ref for a root element (#1541)
 - [fix] Allow empty strings as key props (#1524)
 - [fix] correct the adapter class name
 - [fix] `mount`: make sure it works with native arrow functions (#1667)
 - [refactor]: add “lifecycles” adapter option (#1696)
 - [refactor] use `react-is` package
 - [deps] remove unneeded `lodash` dep; update `prop-types`, `enzyme-adapter-utils`, `object.assign`
 - [dev deps] update `babel-cli`, `babel-core`, `babel-plugin-transform-replace-object-assign`, `babel-preset-airbnb`, `chai`, `coveralls`, `eslint`, `eslint-config-airbnb`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `lerna`, `json-loader`, `karma-firefox-launcher`, `prop-types`, `lerna`, `rimraf`, `webpack`
ljharb added a commit that referenced this pull request Aug 8, 2018
 - [new] add `isFragment` (#1733)
 - [new] Add `displayNameOfNode`, `isValidElementType`
 - [new] `mount`: add `hydrateIn` option (#1317, #1707)
 - [new] Add support for react context element types (#1513)
 - [new] `shallow`: Add getSnapshotBeforeUpdate support (#1657)
 - [fix] portals and roots may render fragments (#1733)
 - [fix] add missing support for animation events (#1569)
 - [fix] `shallow`: SFCs do not get a `this` (#1703)
 - [refactor]: add “lifecycles” adapter option (#1696)
 - [fix] call ref for a root element (#1541)
 - [fix] Allow empty strings as key props (#1524)
 - [fix] Fix ShallowWrapper for array-rendering components (#1498)
 - [refactor] use `react-is` package
 - [meta] ensure a license and readme is present in all packages when published
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.

2 participants