I'm trying to implement something that should allow me to manipulate some modals (using react-modal) more easily. I see a lot of library out there that handle modals in a very simple way, with callback, promises etc... like vex or sweet alert
So far I did not find any way of doing this in a simple way with react. I see a lot of solution which require to write a modal reducer and intercept what you want inside componentWillReceiveProps but I feel like it's a bit heavy.
So far I got to this
https://codesandbox.io/s/l24r14pxp7
I'm using a hoc to pass datas and functions inside my component. I like this method because all the modal logic can stay at the same place, and as react-modal use portals, they are defined within the relevant component.
But I feel like it's a bit "dirty" to store functions directly inside a state. How do you feel about this ? Should I do it in a different way ?