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

Wrap .Invoke() with act to make trigger rerender by handler less error prone #2158

Merged
merged 3 commits into from
Jun 11, 2019

Conversation

chenesan
Copy link
Contributor

@chenesan chenesan commented Jun 9, 2019

This PR expose act call out of enzyme-adapter-react-16 and make the invoke api call handler with act. This will make the added test case passed without explicitly call act(). Before this change, we have to call act() outside of the onClick handler manually, which is easy to forget to do that.

Also update the doc of invoke to encourage people to trigger handler with it (so we don't need to explictly call act() and update()).

docs/api/ReactWrapper/invoke.md Outdated Show resolved Hide resolved
docs/api/ReactWrapper/invoke.md Outdated Show resolved Hide resolved
@@ -495,6 +495,7 @@ class ReactSixteenAdapter extends EnzymeAdapter {
}),
};
},
act: wrapAct,
Copy link
Member

Choose a reason for hiding this comment

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

this is semver-minor in the adapter

packages/enzyme/src/ReactWrapper.js Outdated Show resolved Hide resolved
@ljharb ljharb added this to v16.8+: Hooks in React 16 Jun 10, 2019
@chenesan
Copy link
Contributor Author

@ljharb Just address the review and rebase on master to resolve the conflict :)

@ljharb ljharb force-pushed the invoke-with-act branch 2 times, most recently from 9761bf2 to d2bb655 Compare June 11, 2019 05:59
@ljharb ljharb merged commit d2bb655 into enzymejs:master Jun 11, 2019
@chenesan chenesan deleted the invoke-with-act branch June 11, 2019 06:34
ljharb added a commit that referenced this pull request Oct 9, 2019
 - [new] add Profiler support for react v16.9+ (#2233)
 - [new] add `wrapInvoke` to adapter (#2158)
 - [refactor] use `enzyme-shallow-equal`
 - [dev deps] update `eslint`, `eslint-plugin-react`, `eslint-config-airbnb`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `safe-publish-latest`
 - [meta] Update airbnb.io URLs to use https (#2222)
ljharb added a commit that referenced this pull request Dec 20, 2019
New Stuff
 - `render`: handle Fiber strings and numbers (#2221)

Fixes
 - `shallow`: Share child context logic between `shallow` and `dive` (#2296)
 - `mount`: `children`: include text nodes ($2269)
 - `mount`: `invoke`: use adapter’s `wrapInvoke` if present (#2158)

Docs
 - `mount`/`shallow`: `closest`/`parent`: Add missing arguments description (#2264)
 - `mount`/`shallow`: fix pluralization of “exist” (#2262)
 - `shallow`/`mount`: `simulate`: added functional component example to simulate doc (#2248)
 - `mount`: `debug`: add missing verbose option flag (#2184)
 - `mount`/`shallow`: `update`: fix semantics description (#2194)
 - add missing backticks to linked method names (#2170)
 - `invoke`: Add missing backticks to end of codeblock (#2160)
 - `invoke`: Fix typo (#2167)
 - Explicit React CSS selector syntax description (#2178)

Meta Stuff
 - [meta] add `funding` field
 - [meta] Update airbnb.io URLs to use https (#2222)
 - [deps] update `is-boolean-object`, `is-callable`, `is-number-object`, `is-string`, `enzyme-shallow-equal`, `array.prototype.flat`, `function.prototype.name`, `html-element-map`, `is-r
egex`, `object-inspect`, `object-is`, `object.entries`, `object.vales`, `raf`, `string.prototype.trim`
 - [dev deps] update `eslint`, `eslint-plugin-import`, `eslint-plugin-markdown`, `eslint-plugin-react`, `safe-publish-latest`, `eslint-config-airbnb`, `rimraf`, `safe-publish-latest`, `k
arma-firefox-launcher`, `babel-preset-airbnb`, `glob-gitignore`, `semver`, `eslint-plugin-jsx-a11y`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
React 16
  
v16.8+: Hooks
Development

Successfully merging this pull request may close these issues.

None yet

2 participants