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

Pass state to setState callback #18

Closed
diegohaz opened this issue May 20, 2018 · 0 comments
Closed

Pass state to setState callback #18

diegohaz opened this issue May 20, 2018 · 0 comments
Labels
enhancement New feature or request

Comments

@diegohaz
Copy link
Owner

diegohaz commented May 20, 2018

Since effects and lifecycles have no way to access the updated state in setState callbacks (using this.state), we should provide it.

const increment = () => ({ setState }) => {
  setState(state => ({ count: state.count + 1 }), newState => ...)
}

Another option would be deprecate state prop in favor of a new getState.

@diegohaz diegohaz added the enhancement New feature or request label May 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant