Use preact to render the tree (#155)

* Use preact to render the tree

* More changes to renderHtml
This commit is contained in:
Misode
2021-09-09 21:36:19 +02:00
committed by GitHub
parent b5c994795a
commit 386eb675d6
14 changed files with 409 additions and 500 deletions

20
src/app/hooks/useFocus.ts Normal file
View File

@@ -0,0 +1,20 @@
import { useEffect, useState } from 'preact/hooks'
export function useFocus(): [boolean, () => unknown] {
const [active, setActive] = useState(false)
const hider = () => {
setActive(false)
}
useEffect(() => {
if (active) {
document.body.addEventListener('click', hider)
}
return () => {
document.body.removeEventListener('click', hider)
}
}, [active])
return [active, () => setActive(true)]
}