Skip to content

Commit 20f765b

Browse files
committed
docs(readme): use runnable signal-based examples with note
1 parent b4af14e commit 20f765b

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,32 +68,35 @@ fictReactPreset({
6868
```tsx
6969
import { reactify } from '@fictjs/react'
7070
import { prop } from '@fictjs/runtime'
71+
import { createSignal } from '@fictjs/runtime/advanced'
7172
import { MyButton } from './react/MyButton'
7273

7374
const FictButton = reactify(MyButton)
7475

7576
// In a Fict component
7677
function 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

8283
The 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
8789
import { ReactIsland } from '@fictjs/react'
90+
import { createSignal } from '@fictjs/runtime/advanced'
8891
import { Chart } from './react/Chart'
8992

9093
function 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
/>

0 commit comments

Comments
 (0)