react-use
react-use copied to clipboard
Support portal hook
Hey guys , I think it's good to have custom hook as usePortal , that make easier to use portal for example :
const { Portal, show, hide, isShow, toggle } = usePortal({
escToHide: false,
});
and if we want use it ,
<Portal>
<div
id="modal"
onClick={handleClickBackdrop}>
<div className="modal__body">
<header className="modal__body-header">{children?.header}</header>
{children.body}
</div>
</div>
</Portal>
if it is a good idea i can make a PR
This is a good design, but I think it's unnecessary to implement a complex hook while it can be achieved by multiple simple hooks those are already exist.
For example, I can do the same by combining useToggle + <Portal /> + useKeyboard without looking api docs.