@webkrafters/react-observable-context 4.1.7 → 4.1.8

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 CHANGED
@@ -109,7 +109,9 @@ const Provider = ({ c = 36 }) => {
109
109
  useEffect(() => {
110
110
  // similar to `store.setState`, use the following to update
111
111
  // only the changed slice of the context internal state.
112
- setState({ a: { b: { c } } });
112
+ // Please see `Set State` section
113
+ setState({ a: { b: { c } } }); // OR
114
+ // setState({ a: { b: { c: { '@@REPLACE': c } } } });
113
115
  // Do not do the following: it will override the context internal state.
114
116
  // setState({ ...state, a: { ...state.a, b: { ...state.a.b, c } } });
115
117
  }, [ c ]);
@@ -514,7 +516,7 @@ const state = {
514
516
 
515
517
  store.setState({ '@@REPLACE': { a: 'Demo', j: 17 } }) // rewrites state to { a: 'Demo', j: 17 };
516
518
 
517
- store.setState({ a: { '@@REPLACE': { message: 'Testing...' } } }) // rewrites state.a.b to { message: 'Testing...' }
519
+ store.setState({ a: { '@@REPLACE': { message: 'Testing...' } } }) // rewrites state.a to { message: 'Testing...' }
518
520
 
519
521
  /* rewrites state.a.b[1] to { x: 97, y: 98, z: 99 }; leaving state.a.b = [{ x: 7, y: 8, z: 9 }, { x: 97, y: 98, z: 99 }] */
520
522
  store.setState({ a: { b: [ state.a.b[ 0 ], { '@@REPLACE': { x: 97, y: 98, z: 99 } } ] } })
@@ -527,11 +529,11 @@ store.setState({ a: { b: { 1: { '@@REPLACE': { x: 97, y: 98, z: 99 } } } } })
527
529
 
528
530
  ```jsx
529
531
  /*
530
- This tag is for handling edge cases only. Please use sparingly. In most cases, store.setState with or without any of the other tags is sufficient and most efficient.
531
-
532
- This and the '@@REPLACE' tags are functionally equivalent when used with a replacement value argument.
533
-
534
- Be aware that the compute function argument may be `undefined` for properties which do not yet exist in the state.
532
+ This tag is for handling edge cases only. Please use sparingly. In most cases, store.setState with or without any of the other tags is sufficient and most efficient.
533
+
534
+ This and the '@@REPLACE' tags are functionally equivalent when used with a replacement value argument.
535
+
536
+ Be aware that the compute function argument may be `undefined` for properties which do not yet exist in the state.
535
537
  */
536
538
 
537
539
  const state = {
@@ -541,7 +543,7 @@ const state = {
541
543
 
542
544
  store.setState({ '@@SET': currentValue => ({ ...currentValue, a: 'Demo', j: 17 }) }) // rewrites state to { ...state, a: 'Demo', j: 17 };
543
545
 
544
- store.setState({ a: { '@@SET': currentValue => ({ ...currentValue, message: 'Testing...' }) } }) // rewrites state.a.b to { ...state, message: 'Testing...' }
546
+ store.setState({ a: { '@@SET': currentValue => ({ ...currentValue, message: 'Testing...' }) } }) // rewrites state.a to { ...state, message: 'Testing...' }
545
547
 
546
548
  /* rewrites state.a.b[1] to { x: 97, y: 98, z: 99 }; leaving state.a.b = [{ x: 7, y: 8, z: 9 }, { x: 97, y: 98, z: 99 }] */
547
549
  store.setState({ a: { b: [ state.a.b[ 0 ], { '@@SET': currentValue => ({ ...currentValue, x: 97, y: 98, z: 99 }) } ] } })
@@ -100,7 +100,7 @@ var useStore = function useStore(prehooks, value, storage) {
100
100
  mounted.current = true;
101
101
  return;
102
102
  }
103
- setState((0, _utils.clonedeep)(value));
103
+ setState(value);
104
104
  }, [value]);
105
105
  (0, _react.useEffect)(function () {
106
106
  if (!listeners.size) {
package/package.json CHANGED
@@ -133,5 +133,5 @@
133
133
  "test:watch": "eslint --fix && jest --updateSnapshot --watchAll"
134
134
  },
135
135
  "types": "dist/main/index.d.ts",
136
- "version": "4.1.7"
136
+ "version": "4.1.8"
137
137
  }