diff --git a/versioned_docs/version-5/machines.mdx b/versioned_docs/version-5/machines.mdx index 35278d908..3c8cf2a08 100644 --- a/versioned_docs/version-5/machines.mdx +++ b/versioned_docs/version-5/machines.mdx @@ -110,7 +110,7 @@ const feedbackMachine = createMachine( delays: { /* ... */ }, - } + }, ); ``` @@ -143,6 +143,31 @@ const feedbackActor = interpret(customFeedbackMachine).start(); // logs 'Doing something custom!' ``` +:::warningxstate + +`machine.provide()` is not imperative but rather returns a new machine that includes the implementation overrides. + +Modifying the previous example, if we were to imperatively call `.provide()` on an existing machine, that would **not** change the machine’s behavior with our implementations. + +```ts +// Do NOT do this! +const feedbackMachine = createMachine({...}); + +feedbackMachine.provide({ + actions: { + doSomething: () => { + console.log('Doing something custom!'); + }, + }, +}); + +// This will NOT utilize the provided implementations. +const feedbackActor = interpret(feedbackMachine).start(); + +``` + +::: + ## Specifying types You can specify TypeScript types inside the machine config using the `.types` property: @@ -246,4 +271,4 @@ const machineWithImpls = machine.provide({ /* ... */ }, }); -``` \ No newline at end of file +```