@ptolemy2002/react-proxy-context 1.0.8 → 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.
- package/index.js +1 -1
- 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
|
}
|