DEV Community

Discussion on: New React Hooks Pattern? Return a Component

Collapse
 
droopytersen profile image
Andrew Petersen • Edited

Yeah that's where I landed too. If the hook is coupled to the UI any way, why not? One thing I've been noodling on lately is flipping it. Where component has the hook tacked on it.

import Modal from "./Modal"
// then use the hook like 
let modal = Modal.useModal({ ...stuff } )

// and use the component like 
<Modal {...modal.modalProps }>
  ....
</Modal>
Enter fullscreen mode Exit fullscreen mode
Collapse
 
droopytersen profile image
Andrew Petersen

I took the idea described above and tried to capture it in in a new blog post, Compound Components with a Hook