@ptolemy2002/react-proxy-context 1.0.14 → 1.1.0
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/index.js +3 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -819,15 +819,16 @@ var ProxyContextProvider = (0, import_react_utils.partialMemo)(function ProxyCon
|
|
|
819
819
|
if ((0, import_is_callable.default)(onChange)) onChange(null, objRef.current, prevObj);
|
|
820
820
|
forceRerender();
|
|
821
821
|
}
|
|
822
|
+
contextRef.current.obj = objRef.current;
|
|
822
823
|
return objRef.current;
|
|
823
|
-
}, [onChange
|
|
824
|
+
}, [onChange]);
|
|
824
825
|
if (objRef.current === void 0) objRef.current = set(value);
|
|
825
826
|
contextRef.current.obj = objRef.current;
|
|
826
827
|
contextRef.current.set = set;
|
|
827
828
|
contextRef.current.subscribe = subscribe;
|
|
828
829
|
contextRef.current.unsubscribe = unsubscribe;
|
|
829
830
|
return /* @__PURE__ */ import_react.default.createElement(contextClass.Provider, { value: contextRef.current }, children);
|
|
830
|
-
}, ["onChange", "proxyRef"]);
|
|
831
|
+
}, ["children", "onChange", "proxyRef"]);
|
|
831
832
|
function useProxyContext(contextClass, deps, onChange, listenReinit = true) {
|
|
832
833
|
const context = (0, import_react.useContext)(contextClass);
|
|
833
834
|
const forceRerender = (0, import_react_force_rerender.default)();
|
|
@@ -840,7 +841,6 @@ function useProxyContext(contextClass, deps, onChange, listenReinit = true) {
|
|
|
840
841
|
forceRerender();
|
|
841
842
|
if ((0, import_is_callable.default)(onChange)) onChange(prop, current, prev);
|
|
842
843
|
}, deps, listenReinit);
|
|
843
|
-
forceRerender();
|
|
844
844
|
});
|
|
845
845
|
(0, import_react_mount_effects.useUnmountEffect)(() => {
|
|
846
846
|
context?.unsubscribe(id.current);
|