Skip to content

Instantly share code, notes, and snippets.

View vincsb's full-sized avatar

Vincent Bocquet vincsb

View GitHub Profile
@vincsb
vincsb / after.js
Last active June 21, 2019 09:19
Use @lodash/fp to immutable state change in Redux reducer
import { flow, set } from 'lodash/fp';
const reducer = (state, action) => {
case HIDDEN_POST: {
flow(
set(`posts.${postId}.isHidden`, true ),
set(`posts.${postId}.commentsCount`, 0 ),
)(state);
}
}