Skip to content

Commit 0fbdd95

Browse files
committed
Fix useState to support primitive values in setState
1 parent fa79b34 commit 0fbdd95

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

didact.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ function useState(initial) {
219219
})
220220

221221
const setState = action => {
222-
hook.queue.push(action)
222+
hook.queue.push(typeof action === "function" ? action : (prev) => action)
223223
wipRoot = {
224224
dom: currentRoot.dom,
225225
props: currentRoot.props,
@@ -316,4 +316,4 @@ function Counter() {
316316
}
317317
const element = <Counter />
318318
const container = document.getElementById("root")
319-
Didact.render(element, container)
319+
Didact.render(element, container)

0 commit comments

Comments
 (0)