DEV Community

Discussion on: Render Hook Pattern in React

Collapse
 
tomslutsky profile image
Tom Slutsky

Thanks for responding! glad you found it useful :)
It pretty much the same as rendering the component and controlling it with state held by the parent component.
I actually had a doubt about it because I needed the modal for alerting the user before deleting item from a list, So it looked like I will need a Modal for each item. However I ended up using only one modal component by introducing the ability to pass arguments to the function toggling the modal.
I case you found the performance not sufficient enough (which I really doubt), I guess you can use context provider to render the modal only once in your component tree and controlling it with a hook.
If it sounds interesting to you let me know and I might write an example of that.