react-native-global-state-hooks 3.0.4 → 3.0.5
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.
- package/README.md +5 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -143,17 +143,14 @@ You could just use this code right as it is by just adding also into your projec
|
|
|
143
143
|
|
|
144
144
|
```ts
|
|
145
145
|
import asyncStorage from '@react-native-async-storage/async-storage';
|
|
146
|
+
import { clone, formatFromStore, formatToStore } from 'json-storage-formatter';
|
|
146
147
|
|
|
147
148
|
import {
|
|
148
|
-
ActionCollectionConfig,
|
|
149
|
-
formatFromStore,
|
|
150
|
-
formatToStore,
|
|
151
149
|
GlobalStore as GlobalStoreBase,
|
|
150
|
+
ActionCollectionConfig,
|
|
152
151
|
StateChangesParam,
|
|
153
152
|
StateConfigCallbackParam,
|
|
154
153
|
StateSetter,
|
|
155
|
-
isPrimitive,
|
|
156
|
-
isDate,
|
|
157
154
|
} from 'react-native-global-state-hooks';
|
|
158
155
|
|
|
159
156
|
/**
|
|
@@ -225,7 +222,7 @@ export class GlobalStore<
|
|
|
225
222
|
|
|
226
223
|
/**
|
|
227
224
|
* This method will be called once the store is created after the constructor,
|
|
228
|
-
* this method is different from the onInit of the
|
|
225
|
+
* this method is different from the onInit of the config property and it won't be overridden
|
|
229
226
|
*/
|
|
230
227
|
protected onInit = async ({
|
|
231
228
|
setState,
|
|
@@ -247,10 +244,10 @@ export class GlobalStore<
|
|
|
247
244
|
});
|
|
248
245
|
|
|
249
246
|
if (storedItem === null) {
|
|
250
|
-
const
|
|
247
|
+
const state = clone(this.state);
|
|
251
248
|
|
|
252
249
|
// this forces the react to re-render the component when the state is an object
|
|
253
|
-
return setState(
|
|
250
|
+
return setState(state);
|
|
254
251
|
}
|
|
255
252
|
|
|
256
253
|
const jsonParsed = JSON.parse(storedItem);
|
package/package.json
CHANGED