@ptolemy2002/react-proxy-context 1.0.6 → 1.0.7

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/index.js +4 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -358,6 +358,7 @@ function ProxyContextProvider({ contextClass, children, value, onChange, proxyRe
358
358
  const changeSubscribers = (0, import_react.useRef)({});
359
359
  const objRef = (0, import_react.useRef)();
360
360
  const contextRef = (0, import_react.useRef)({});
361
+ const forceRerender = (0, import_react_force_rerender.default)();
361
362
  const subscribe = (0, import_react.useCallback)((callback, deps, listenReinit = true) => {
362
363
  const id = nanoid();
363
364
  changeSubscribers.current[id] = {
@@ -400,6 +401,8 @@ function ProxyContextProvider({ contextClass, children, value, onChange, proxyRe
400
401
  return true;
401
402
  }
402
403
  });
404
+ } else {
405
+ objRef.current = newObj;
403
406
  }
404
407
  Object.values(changeSubscribers.current).forEach((subscriber) => {
405
408
  if (subscriber.listenReinit) {
@@ -408,6 +411,7 @@ function ProxyContextProvider({ contextClass, children, value, onChange, proxyRe
408
411
  });
409
412
  proxyRef && (proxyRef.current = objRef.current);
410
413
  if ((0, import_is_callable.default)(onChange)) onChange(null, objRef.current, prevObj);
414
+ forceRerender();
411
415
  }
412
416
  return objRef.current;
413
417
  }, [onChange, proxyRef]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptolemy2002/react-proxy-context",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "main": "index.js",
5
5
  "files": [
6
6
  "index.js"