-
For example: import { createBrowserInspector } from "@statelyai/inspect";
import { createActorContext } from "@xstate/react";
import { ReactNode } from "react";
import { appMachine } from "./stateMachine";
export const PERSISTED_SNAPSHOT_KEY = "persistedSnapshot";
const { inspect } = createBrowserInspector({ autoStart: false });
export const AppMachineContext = createActorContext(appMachine, {
snapshot: JSON.parse(localStorage.getItem(PERSISTED_SNAPSHOT_KEY) || "null"),
inspect,
});
export default function AppMachineContextProvider(
{ children }: { children: ReactNode },
) {
return <AppMachineContext.Provider>{children}</AppMachineContext.Provider>;
} It create the actor with the snapshot yes, but it's only set the snapshot for the mother/root actor, not for children actors. I checked the {
"status": "active",
"value": {
"main": {
"scenes": "home",
"navigation": {}
}
},
"historyValue": {},
"context": {
"signedIn": true,
"username": "User",
"userDateOfBirth": "Tue Jan 01 1924",
"userGender": "female"
},
"children": {
"home": {
"snapshot": {
"status": "active",
"value": "init",
"historyValue": {},
"context": {},
"children": {}
},
"src": "home",
"syncSnapshot": false
}
}
} How can I |
Beta Was this translation helpful? Give feedback.
Answered by
NNBnh
Dec 11, 2024
Replies: 1 comment
-
No sorry I'm wrong, the |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
NNBnh
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No sorry I'm wrong, the
createActorContext
do create withpersistedSnapshot
recursively but the system I use to savepersistedSnapshot
it's not.