Skip to content

Commit

Permalink
Update templates (#4519)
Browse files Browse the repository at this point in the history
* Update templates

* Update to latest
  • Loading branch information
davidkpiano authored Nov 29, 2023
1 parent 15634c2 commit 7916400
Show file tree
Hide file tree
Showing 22 changed files with 855 additions and 4,452 deletions.
2 changes: 1 addition & 1 deletion templates/react-ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ A starting point template for using XState with React and TypeScript. Create a f

Using [Vite](https://vitejs.dev/) as a build tool and to run the local development server.

## [➡️ Open in CodeSandbox](https://codesandbox.io/p/sandbox/github/statelyai/xstate/tree/main/templates/react-ts?file=%2Fsrc%2FfeedbackMachine.ts)
## [➡️ Open in CodeSandbox](https://codesandbox.io/p/sandbox/github/statelyai/xstate/tree/next/templates/react-ts?file=%2Fsrc%2FfeedbackMachine.ts)
8 changes: 4 additions & 4 deletions templates/react-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
"preview": "vite preview"
},
"dependencies": {
"@xstate/react": "4.0.0-beta.9",
"@xstate/react": "4.0.0-beta.11",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"xstate": "5.0.0-beta.29"
"xstate": "5.0.0-beta.49"
},
"devDependencies": {
"@types/react": "^18.2.37",
"@types/react-dom": "^18.2.15",
"@types/react": "^18.2.39",
"@types/react-dom": "^18.2.17",
"@vitejs/plugin-react": "^3.1.0",
"typescript": "^4.9.5",
"vite": "^4.5.0"
Expand Down
943 changes: 578 additions & 365 deletions templates/react-ts/pnpm-lock.yaml

Large diffs are not rendered by default.

52 changes: 27 additions & 25 deletions templates/react-ts/src/feedbackMachine.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
import { assign, createMachine } from 'xstate';
import { assign, setup } from 'xstate';

const types = {
context: {} as { feedback: string },
events: {} as
| {
type: 'feedback.good';
}
| {
type: 'feedback.bad';
}
| {
type: 'feedback.update';
value: string;
}
| { type: 'submit' }
| {
type: 'close';
}
| { type: 'back' }
| { type: 'restart' }
};

export const feedbackMachine = createMachine({
export const feedbackMachine = setup({
types: {
context: {} as { feedback: string },
events: {} as
| {
type: 'feedback.good';
}
| {
type: 'feedback.bad';
}
| {
type: 'feedback.update';
value: string;
}
| { type: 'submit' }
| {
type: 'close';
}
| { type: 'back' }
| { type: 'restart' }
},
guards: {
feedbackValid: ({ context }) => context.feedback.length > 0
}
}).createMachine({
id: 'feedback',
initial: 'prompt',
types,
context: {
feedback: ''
},
Expand All @@ -44,7 +46,7 @@ export const feedbackMachine = createMachine({
},
back: { target: 'prompt' },
submit: {
guard: ({ context }) => context.feedback.length > 0,
guard: 'feedbackValid',
target: 'thanks'
}
}
Expand Down
11 changes: 0 additions & 11 deletions templates/svelte-ts/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion templates/svelte-ts/.npmrc

This file was deleted.

7 changes: 0 additions & 7 deletions templates/svelte-ts/README.md

This file was deleted.

Loading

0 comments on commit 7916400

Please sign in to comment.