Hey everyone! I've just released react-easy-modals, a simple modal manager with zero dependencies. It's basically a React port of the wonderful svelte-modals.
This pattern to invoke a modal is pretty useful though. I'm experimenting with a hook that returns an anchor component in order to implement the accessibility functionality. Not sure if that's a good idea yet:
const [ModalAnchor, showModal] = useModal()
function handleClick() {
showModal(<MyModal />)
}
return <ModalAnchor>
<button onClick={handleClick}>Open</button>
<ModalAnchor>