Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
before-immer
const like = item => ({
type: like.type,
payload: item
});
like.type = 'user/like';
const initialState = {
name: 'Anonymous',
avatar: 'Anonymous',
email: '',
walletAddress: '',
likes: {}
};
// Before immer
const reducer = (state = initialState, { type, payload } = {}) => {
switch (type) {
case like.type: {
return {
...state,
likes: {
...state.likes,
[payload.id]: payload
}
};
}
default:
return state;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.