UNPKG

collaborative-ui

Version:

React component library for building real-time collaborative editing applications.

19 lines (18 loc) 560 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useStore = void 0; const react_1 = require("react"); const useStore = (store) => { const view = (0, react_1.useSyncExternalStore)(store.subscribe, () => { // This try is not necessary one this is fixed: https://github.com/streamich/json-joy/issues/708 try { return store.getSnapshot(); } catch (e) { console.error(e); return undefined; } }); return view; }; exports.useStore = useStore;