Skip to content

Separate setWithCallback support from set in facet #13

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

Merged
merged 4 commits into from
Nov 17, 2021

Conversation

xaviervia
Copy link
Contributor

Currently, facets accept both functions and values to be passed into .set. This leads to the problem that, if the value is supposed to be a function, .set will immediately invoke that function, thinking that it is a callback.

This PR separates this behavior into a different method, .setWithCallback.

Note that useFacetState is kept with the same behavior as before, since the intent is to match useState's API from React.

@xaviervia xaviervia requested a review from pirelenito November 17, 2021 10:17
Copy link
Member

@pirelenito pirelenito left a comment

Choose a reason for hiding this comment

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

Awesome stuff 🎉

Pushed one small change to simplify some tests.

@pirelenito pirelenito merged commit 74b0b9f into main Nov 17, 2021
@pirelenito pirelenito deleted the separate-setter-support-from-set-in-facet branch November 17, 2021 15:40
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