tajo/react-portal

Function as children

chbdetta opened this issue · 2 comments

What about adding the support for function children so codes below can be valid

<Portal openByClickOn ={<a>test</a>}>{(closePortal) => (
  <Modal>
    {/*some content*/}
    <button onClick={closePortal()}>close me</button>
  </Modal>
)}</Portal>

I could just inline the portal content without creating a component class / stateless functional comp to use the closePortal

tajo commented

Yes. This is a great pattern and I will use it in v4.

tajo commented

Used in #157