Fix: remove bootstrapStartedRef that deadlocks persistence in StrictMode

The bootstrapStartedRef guard prevented the second StrictMode effect
invocation from running, while the first invocation's async work saw
disposed=true and skipped setPersistenceReady(true). This left
persistenceReady permanently false, disabling state loading and
persistence during development.

The disposed flag alone correctly handles cleanup of stale effect
invocations, making the ref guard unnecessary.
This commit is contained in:
Cursor Agent committed 2026-02-18 05:27:53 +00:00
1 parent 4d976b8bf7
commit 707889950d
1 file changed
-4
-4
View File
@@ -858,13 +858,9 @@ const StoreContext = createContext<{
export function StoreProvider({ children }: { children: ReactNode }) {
const [state, dispatch] = useReducer(reducer, initialState);
const [persistenceReady, setPersistenceReady] = useState(false);
const bootstrapStartedRef = useRef(false);
const lastPersistedStateJsonRef = useRef<string | null>(null);
useEffect(() => {
if (bootstrapStartedRef.current) return;
bootstrapStartedRef.current = true;
let disposed = false;
const api = readNativeApi();
if (!api) {