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

Callback function in set state #9

Conversation

hjvvoorthuijsen
Copy link
Contributor

Why

When using the useState hook of react you can set the state in two ways:

  • With a direct value
  • With a callback that gets the previous state as a parameter and will set the state to the returned value

The second use of the set state function doesn't work with Jooks.

What has changed

  • Added a test to show the use of the callback (fails in the current version)
  • Modified the useStateMock to enable the use of a callback

@antoinejaussoin antoinejaussoin merged commit e71fa50 into antoinejaussoin:master Jun 17, 2020
@antoinejaussoin
Copy link
Owner

Thanks a lot for your contribution! Will publish a new version with your change today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants