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

2 participants
@chenesan
Copy link
Contributor

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()).

chenesan added some commits Jun 9, 2019

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

This comment has been minimized.

Copy link
@ljharb

ljharb Jun 10, 2019

Member

this is semver-minor in the adapter

Show resolved Hide resolved packages/enzyme/src/ReactWrapper.js Outdated

@ljharb ljharb added this to v16.8+: Hooks in React 16 Jun 10, 2019

@chenesan chenesan force-pushed the chenesan:invoke-with-act branch from 18dad79 to b5281db Jun 11, 2019

@chenesan

This comment has been minimized.

Copy link
Contributor Author

commented Jun 11, 2019

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

@chenesan chenesan force-pushed the chenesan:invoke-with-act branch from acfcf0b to b5281db Jun 11, 2019

@ljharb ljharb force-pushed the chenesan:invoke-with-act branch from b5281db to c4a38a0 Jun 11, 2019

@ljharb

ljharb approved these changes Jun 11, 2019

@ljharb ljharb force-pushed the chenesan:invoke-with-act branch 2 times, most recently from 9761bf2 to d2bb655 Jun 11, 2019

@ljharb ljharb merged commit d2bb655 into airbnb:master Jun 11, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@chenesan chenesan deleted the chenesan:invoke-with-act branch Jun 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.