File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,32 +68,35 @@ fictReactPreset({
6868``` tsx
6969import { reactify } from ' @fictjs/react'
7070import { prop } from ' @fictjs/runtime'
71+ import { createSignal } from ' @fictjs/runtime/advanced'
7172import { MyButton } from ' ./react/MyButton'
7273
7374const FictButton = reactify (MyButton )
7475
7576// In a Fict component
7677function App() {
77- let count = $state (0 )
78- return <FictButton label = { prop (() => ` Clicked ${count } times ` )} />
78+ const count = createSignal (0 )
79+ return <FictButton label = { prop (() => ` Clicked ${count () } times ` )} />
7980}
8081```
8182
8283The React component re-renders whenever the reactive props change — without re-running the Fict component function.
84+ If your app uses Fict compiler macros, you can write an equivalent ` $state(...) ` style.
8385
8486### 3. Declarative Island
8587
8688``` tsx
8789import { ReactIsland } from ' @fictjs/react'
90+ import { createSignal } from ' @fictjs/runtime/advanced'
8891import { Chart } from ' ./react/Chart'
8992
9093function Dashboard() {
91- let data = $state ([])
94+ const data = createSignal < number []> ([])
9295
9396 return (
9497 <ReactIsland
9598 component = { Chart }
96- props = { () => ({ data , height: 300 })}
99+ props = { () => ({ data: data () , height: 300 })}
97100 client = " visible"
98101 ssr
99102 />
You can’t perform that action at this time.
0 commit comments