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

Add Immer functionality #1

Open
BigAB opened this issue Jul 10, 2019 · 0 comments
Open

Add Immer functionality #1

BigAB opened this issue Jul 10, 2019 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@BigAB
Copy link
Owner

BigAB commented Jul 10, 2019

Simple is better.

Having to write non mutating code can become tedious:

const item = state.find(item => item.id === payload.id);
const index = state.indexOf(item);
return [...state.slice(0, index), { ...item, selected: true }, ...state.slice(index + 1)]'

better to just pass an immer draft object and let the user mutate it, but still give immutable state updates.

const item = state.find(item => item.id === payload.id);
item.selected = true;
return state;
@BigAB BigAB added the enhancement New feature or request label Jul 10, 2019
@BigAB BigAB self-assigned this Jul 10, 2019
@BigAB BigAB modified the milestones: Make it right, Make it work Jul 10, 2019
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