#Error: You used a hook from "ActorProvider(mymachinename)" but it's not inside a <ActorProvider

1 messages · Page 1 of 1 (latest)

lilac iron
#

Create the machine in a different file, then import it into the file you want to use createActorContext in.

import { createActorContext } from "@xstate/react";
import { myMachine } from "./machines/myMachine";

export const MyMachineContext = createActorContext(myMachine);
#

...then do

<MyMachineContext.Provider>
  {children}
</MyMachineContext.Provider>
#

Does that help?

red snow
#

no - actually the machine works until there is one statechange that causes that error

#

so the provider for some reason "disapears"