react-redux-cache 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +22 -1
  2. package/package.json +1 -2
package/README.md CHANGED
@@ -17,6 +17,7 @@ Usage example can be found in `example/` folder and run by `npm run example` com
17
17
  - [api.ts](https://github.com/gentlee/react-redux-cache#apits)
18
18
  - [Usage](https://github.com/gentlee/react-redux-cache#usage)
19
19
  - [Advanced](https://github.com/gentlee/react-redux-cache#advanced)
20
+ - [redux-persist](https://github.com/gentlee/react-redux-cache#redux-persist)
20
21
 
21
22
  ### Installation
22
23
  `react` and `redux` are peer dependencies.
@@ -116,4 +117,24 @@ export const UserScreen = () => {
116
117
  ```
117
118
 
118
119
  ### Advanced
119
- To be done...
120
+ #### redux-persist
121
+
122
+ Here is a simple `redux-persist` configuration:
123
+
124
+ ```typescript
125
+ // removes `loading` and `error` from persisted state
126
+ function stringifyReplacer(key: string, value: unknown) {
127
+ return key === 'loading' || key === 'error' ? undefined : value
128
+ }
129
+
130
+ const persistedReducer = persistReducer(
131
+ {
132
+ key: 'cache',
133
+ storage,
134
+ whitelist: ['entities', 'queries'], // mutations are ignored
135
+ throttle: 1000, // ms
136
+ serialize: (value: unknown) => JSON.stringify(value, stringifyReplacer),
137
+ },
138
+ reducer
139
+ )
140
+ ```
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "react-redux-cache",
3
3
  "author": "Alexander Danilov",
4
4
  "license": "MIT",
5
- "version": "0.0.9",
5
+ "version": "0.0.10",
6
6
  "description": "Powerful data fetching and caching library that supports normalization, built on top of redux",
7
7
  "main": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
@@ -36,7 +36,6 @@
36
36
  "react-router-dom": "6.18.0",
37
37
  "redux": "4.2.1",
38
38
  "redux-logger": "3.0.6",
39
- "redux-persist": "6.0.0",
40
39
  "ts-jest": "29.1.0",
41
40
  "typescript": "5.0.4"
42
41
  },