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

[FEATURE] Passing a function for draft or value for direct state usage #76

Merged
merged 2 commits into from
Mar 20, 2021
Merged

Conversation

blackshot
Copy link
Contributor

@blackshot blackshot commented Mar 18, 2021

This PR enables the useImmer hook to be used as a normal useState passing a value as argument with still allowing the user to use the immer feature.

const [state, setState] = useImmer([]);

// normal setState usage
    setState(["this", "is", "the", "new", "state"]);
// or immer usage
    setState( draft => {
        draft.push("my new item")
    });

@mweststrate
Copy link
Collaborator

Thanks for the PR! LGTM, but would you mind updating the documentation as well? Thanks!

@mweststrate mweststrate merged commit 324b0db into immerjs:master Mar 20, 2021
@mweststrate
Copy link
Collaborator

Published as 0.5.0

mweststrate pushed a commit that referenced this pull request Mar 20, 2021
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