Open jeremygottfried opened 2 years ago
FYI, check out the way it's done on https://github.com/httptoolkit/react-reverse-portal
They figured out a way to keep it declarative with InPortal
and OutPortal
components so they can still enforce rules related to how the component is rendered.
Hi, thank you so much for putting the effort into building this! I think this would be super useful if it was a little more declarative in line with other modern libraries like
react-dnd
andreact-spring
. CallingsendReparentableChild
manually is a side effect and makes it much harder to use the library.My suggestion is to have something like this:
In the example above,
child
would be stored in memory so it can be passed around to components that render conditionally. Having a hook that handles "sending" to different parents would make this library much more intuitive. I could see it being something as simple as that hook callingsendReparentableChild
under the hood, with slightly more functionality to make it work for conditional rendering.Just food for thought!