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.
Files changed (2) hide show
  1. package/README.md +5 -8
  2. 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 confg property and it won't be overriden
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 isPrimitiveState = isPrimitive(this.state) && !isDate(this.state);
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(isPrimitiveState ? this.state : { ...this.state });
250
+ return setState(state);
254
251
  }
255
252
 
256
253
  const jsonParsed = JSON.parse(storedItem);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-global-state-hooks",
3
- "version": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "description": "This is a package to easily handling global-state across your react-native-components No-redux",
5
5
  "main": "lib/bundle.js",
6
6
  "types": "lib/index.d.ts",