Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/raphaelkieling/reecreate
An easy way to clone objects for reducers
https://github.com/raphaelkieling/reecreate
javascript react reducer redux
Last synced: 2 days ago
JSON representation
An easy way to clone objects for reducers
- Host: GitHub
- URL: https://github.com/raphaelkieling/reecreate
- Owner: raphaelkieling
- Created: 2021-03-20T01:08:30.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-03-22T02:42:55.000Z (over 3 years ago)
- Last Synced: 2024-09-21T23:41:27.927Z (about 2 months ago)
- Topics: javascript, react, reducer, redux
- Language: TypeScript
- Homepage:
- Size: 187 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Reecrate
Reecrate is a library to clone deep object to minimize the work that is clone a big store using the concept from redux "Immutable Update patterns", see in https://redux.js.org/recipes/structuring-reducers/immutable-update-patterns/
### Install
```
yarn add reecrate
npm install --save reecrate
```Without Reecrate:
```js
const appReducer = (state, action) => {
switch (action.type) {
case "SET_DEEP_LOAD":
return {
...state,
screens: {
...state.screens,
loaders: {
...state.screens.loaders,
someScreen: {
...state.screens.loaders.someScreen,
active: true,
},
},
},
};
}return state;
};
```With Reecrate:
```js
const appReducer = Reecrate.reducer((draft, action) => {
switch (action.type) {
case "SET_DEEP_LOAD":
draft.screens.loaders.someScreen.active = true;
}return draft;
});
```