UNPKG

synapse-react-client

Version:

[![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synapse-react-client) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettie

30 lines (29 loc) 974 B
import { jsx as d } from "react/jsx-runtime"; import l from "lodash-es/noop"; import { createContext as a, useContext as c, useSyncExternalStore as g } from "react"; const i = a({ isEditing: !1, setIsEditing: l }); function b(t) { const { subscribe: e, getSnapshot: n, setIsEditing: o, children: s } = t, r = g(e, n, () => !1); return /* @__PURE__ */ d(i.Provider, { value: { isEditing: r, setIsEditing: o }, children: s }); } function f() { const t = c(i); return t === void 0 ? (console.warn( "useGlobalIsEditingContext should be used within a GlobalIsEditingContextProvider. Editing state will not be tracked!" ), { isEditing: !1, setIsEditing: () => { console.warn( "setIsEditing called outside of a GlobalIsEditingContextProvider. Editing state will not be tracked!" ); } }) : t; } export { b as GlobalIsEditingContextProvider, f as useGlobalIsEditingContext }; //# sourceMappingURL=GlobalIsEditingContext.js.map