I just used your article to create a hook that returns a textEditor (the JSX) and the functions that my component needs.
My line of thought was : If the JSX is tied to the the functions, it makes more sense to use a hook that gives everything instead of importing the JSX separately.
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>
I just used your article to create a hook that returns a textEditor (the JSX) and the functions that my component needs.
My line of thought was : If the JSX is tied to the the functions, it makes more sense to use a hook that gives everything instead of importing the JSX separately.
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.
I took the idea described above and tried to capture it in in a new blog post, Compound Components with a Hook