paol-imi / react-reparenting

The reparenting tools for React
https://paol-imi.github.io/react-reparenting
MIT License
481 stars 8 forks source link

Any way we can set new classes or props for the child when it's re-parented to other parent ? #9

Closed roshangm1 closed 4 years ago

roshangm1 commented 4 years ago

First of all, awesome library. Thanks very much for this. I have a use case where I have big stream player in a channel just like twitch. When moving away from the channel, the player should be now be seen in a small player at the bottom. For this, I have setup of global component at top. I need to reparent the big player from channel to this global component. I was able to do that successfully, but the child has different styles (like height for example) when it's big in channel versus in small player.

How can I achieve this ? Is it possible to add new props to the very child ? or Classes ? while re-parenting ?

paol-imi commented 4 years ago

The Reparenting process provided by this package is composed of the simple re-rendering of the component.

You can approach your problem as you would with any other react component: you can pass new props, use different contexts, or use any other tool provided by react.