SolidJS in 59 Seconds
Code Examples
SolidJS docs ↗Click Increment in either preview to update both counters.
Both counters: 0

SolidJS
import { createSignal } from 'solid-js'
function Counter() {
const [count, setCount] = createSignal(0)
return (
<section>
<button onClick={() => setCount((n) => n + 1)}>
Increment ({count()})
</button>
<p>Current count: <span>{count()}</span></p>
</section>
)
}
Both count() bindings update directly. SolidJS does not call Counter() again.
Current count: 0
'/%3e%3cellipse%20rx='11'%20ry='4.2'%20transform='rotate(120)'/%3e%3c/g%3e%3c/svg%3e)
React
import { useState } from 'react'
function Counter() {
const [count, setCount] = useState(0)
return (
<section>
<button onClick={() => setCount((n) => n + 1)}>
Increment ({count})
</button>
<p>Current count: <span>{count}</span></p>
</section>
)
}
React calls Counter() again and compares the result.