Minor bug
mcjazzyfunky opened this issue · comments
mcjazzyfunky commented
The following error may only occur if you are writing very clumsy code (actually, it took me quite a while to reproduce that issue).
Please see the following demo (open the console then click the button and have a look at error output in the console):
https://codesandbox.io/s/charming-rgb-7qpsx
Zolmeister commented
Shorter reproduction:
import { h, render, Boundary, useCallback, useState } from 'dyo'
function ErrorTrigger() {
throw new Error()
}
function ErrorBoundary() {
const
[error, setError] = useState(null),
onError = useCallback(error => {
setError(error.message)
}, [])
return h(Boundary, { fallback: onError },
error
? h('div', 'Error')
: h(ErrorTrigger)
)
}
console.clear()
const content =
h('div', null, h(ErrorBoundary))
// as working alternative to `content`
const content2 =
h(ErrorBoundary)
// FYI: If you use `content2` instead of `content`
// then the error does not occur
render(content, document.getElementById('app'))
mcjazzyfunky commented
@thysultan Thanks ... I've tested it => seems to work now.