@ptolemy2002/react-proxy-context 1.0.7 → 1.0.9

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 +2 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -359,6 +359,7 @@ function ProxyContextProvider({ contextClass, children, value, onChange, proxyRe
359
359
  const objRef = (0, import_react.useRef)();
360
360
  const contextRef = (0, import_react.useRef)({});
361
361
  const forceRerender = (0, import_react_force_rerender.default)();
362
+ (0, import_react.useImperativeHandle)(proxyRef, () => objRef.current, [objRef.current]);
362
363
  const subscribe = (0, import_react.useCallback)((callback, deps, listenReinit = true) => {
363
364
  const id = nanoid();
364
365
  changeSubscribers.current[id] = {
@@ -409,7 +410,6 @@ function ProxyContextProvider({ contextClass, children, value, onChange, proxyRe
409
410
  subscriber.callback(null, objRef.current, prevObj);
410
411
  }
411
412
  });
412
- proxyRef && (proxyRef.current = objRef.current);
413
413
  if ((0, import_is_callable.default)(onChange)) onChange(null, objRef.current, prevObj);
414
414
  forceRerender();
415
415
  }
@@ -434,6 +434,7 @@ function useProxyContext(contextClass, deps, onChange, listenReinit = true) {
434
434
  forceRerender();
435
435
  if ((0, import_is_callable.default)(onChange)) onChange(prop, current, prev);
436
436
  }, deps, listenReinit);
437
+ forceRerender();
437
438
  });
438
439
  (0, import_react_mount_effects.useUnmountEffect)(() => {
439
440
  context?.unsubscribe(id.current);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptolemy2002/react-proxy-context",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "main": "index.js",
5
5
  "files": [
6
6
  "index.js"