Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tanaypratap/be462d4880db3f37a27aff54f049fffa to your computer and use it in GitHub Desktop.
Save tanaypratap/be462d4880db3f37a27aff54f049fffa to your computer and use it in GitHub Desktop.
Array actions for Redux State Return
const addCounter = (list) => {
return [...list, 0];
};
const removeCounter = (list, index) => {
return [
...list.slice(0, index),
...list.slice(index + 1)
];
};
const incrementCounter = (list, index) => {
return [
...list.slice(0, index),
list[index] + 1,
...list.slice(index + 1)
];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment