MCPcopy
hub / github.com/statelyai/xstate / Provider

Function Provider

packages/xstate-react/src/createActorContext.ts:27–54  ·  view source on GitHub ↗
({
    children,
    logic: providedLogic = actorLogic,
    machine,
    options: providedOptions
  }: {
    children: React.ReactNode;
    logic: TLogic;
    /** @deprecated Use `logic` instead. */
    machine?: never;
    options?: ActorOptions<TLogic>;
  })

Source from the content-addressed store, hash-verified

25 const OriginalProvider = ReactContext.Provider;
26
27 function Provider({
28 children,
29 logic: providedLogic = actorLogic,
30 machine,
31 options: providedOptions
32 }: {
33 children: React.ReactNode;
34 logic: TLogic;
35 /** @deprecated Use `logic` instead. */
36 machine?: never;
37 options?: ActorOptions<TLogic>;
38 }) {
39 if (machine) {
40 throw new Error(
41 `The "machine" prop has been deprecated. Please use "logic" instead.`
42 );
43 }
44
45 const actor = useActorRef(providedLogic, {
46 ...actorOptions,
47 ...providedOptions
48 });
49
50 return React.createElement(OriginalProvider, {
51 value: actor,
52 children
53 });
54 }
55
56 // TODO: add properties to actor ref to make more descriptive
57 Provider.displayName = `ActorProvider`;

Callers

nothing calls this directly

Calls 1

useActorRefFunction · 0.90

Tested by

no test coverage detected