collaborative-ui
Version:
React component library for building real-time collaborative editing applications.
25 lines (24 loc) • 900 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.StrAdapter = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const StoreStrFacade_1 = require("collaborative-editor/lib/replicated-str/StoreStrFacade");
const ReplicatedStr_1 = require("collaborative-editor/lib/replicated-str/ReplicatedStr");
const StrAdapter = ({ store, path, children }) => {
const str = React.useMemo(() => {
try {
const substore = path ? store.bind(path) : store;
const facade = new StoreStrFacade_1.StoreStrFacade(substore);
const str = new ReplicatedStr_1.ReplicatedStr(facade);
return () => str;
}
catch (err) {
return null;
}
}, [store, path]);
if (!str)
return null;
return children(str);
};
exports.StrAdapter = StrAdapter;
;