MCPcopy Create free account
hub / github.com/microsoft/SandDance / useRefEffect

Function useRefEffect

docs/app/js/sanddance-app.js:34779–34798  ·  view source on GitHub ↗
(callback, initial)

Source from the content-addressed store, hash-verified

34777 */ parcelHelpers.export(exports, "useRefEffect", ()=>useRefEffect);
34778var _react = require("react");
34779function useRefEffect(callback, initial) {
34780 if (initial === void 0) initial = null;
34781 var data = _react.useRef({
34782 ref: Object.assign(function(value) {
34783 if (data.ref.current !== value) {
34784 if (data.cleanup) {
34785 data.cleanup();
34786 data.cleanup = undefined;
34787 }
34788 data.ref.current = value;
34789 if (value !== null) data.cleanup = data.callback(value);
34790 }
34791 }, {
34792 current: initial
34793 }),
34794 callback: callback
34795 }).current;
34796 data.callback = callback;
34797 return data.ref;
34798}
34799
34800},{"react":"8ePka","@parcel/transformer-js/src/esmodule-helpers.js":"jA2du"}],"jsoAX":[function(require,module,exports) {
34801var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected