You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The react example won't work in strict mode. It depends on useEffect and useMemo running the same number of times, which isn't guaranteed, and strict mode deliberately runs useEffect double to expose it. I don't think this matters much, but it might be worth it to change the example to
exportconstApp=()=>{const[state,setState]=useState(null);useEffect(()=>{constyProvider=newYjsProvider()// Eg. HocuspocusProvider or WebrtcProviderconstyMap=yProvider.document.getMap('data')setState({ yMap, yProvider });return()=>{yProvider.destroy()}},[])if(!state)return;const{yMap, yProvider}=state;return(<SyncYJsonyMap={yMap}// YMap to be observed for remote changes by yMap.observeDeepsetData={setData}// Action creator to be called as dispatch(setData(data))selectData={selectData}// Selector to be used as useSelector(selectData)/>// Inside other components you can interact with the synced data as with any normal// Redux state by using dispatch and useSelector and it will be seamlessly kept in sync.<OtherComponent/>)}
The text was updated successfully, but these errors were encountered:
The react example won't work in strict mode. It depends on useEffect and useMemo running the same number of times, which isn't guaranteed, and strict mode deliberately runs useEffect double to expose it. I don't think this matters much, but it might be worth it to change the example to
The text was updated successfully, but these errors were encountered: