You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature Request - remove dependency for react-dom in Transition
Recently, I used react-transition-group to manage route-transitions in a React-/React-Native App and stumbled upon a bug in my project, where the react-native runtime would tell me, that there are more than one react-driver running. After brief investigations, I found out, that I used Transition, which directly imports react-dom. My solution was to copy the implementation of Transition and refactor the code, so that it gives you a ref, not a DOM-Node.
Example code below:
classTransitionextendsComponent{// ...updateStatus(mounting=false){letnextStatus=this.nextStatus;if(nextStatus!==null){this.nextStatus=null;// nextStatus will always be ENTERING or EXITING.this.cancelNextCallback();constnode=this.child;if(nextStatus===ENTERING){this.performEnter(node,mounting);}else{this.performExit(node);}}elseif(this.props.unmountOnExit&&this.state.status===EXITED){this.setState({status: UNMOUNTED});}}render(){// ...if(typeofchildren==='function'){returnReact.cloneElement(children(status,childProps),{
...childProps,ref: child=>(this.child=child),});}constchild=React.Children.only(children);returnReact.cloneElement(child,{
...childProps,ref: child=>(this.child=child),});}}
My implementation has no claim to be the perfect solution, so bear with me.
What I am trying to say is, that I propose to remove the dependency to react-dom in favour of a more generic implementation. So if I would wish to work with the DOM-Node directly, I should use ReactDOM.findDOMNode myself as the user of react-transition-group.
What do you think?
Thank you :)
The text was updated successfully, but these errors were encountered:
Feature Request - remove dependency for
react-dom
inTransition
Recently, I used
react-transition-group
to manage route-transitions in a React-/React-Native App and stumbled upon a bug in my project, where the react-native runtime would tell me, that there are more than one react-driver running. After brief investigations, I found out, that I usedTransition
, which directly importsreact-dom
. My solution was to copy the implementation ofTransition
and refactor the code, so that it gives you a ref, not a DOM-Node.Example code below:
My implementation has no claim to be the perfect solution, so bear with me.
What I am trying to say is, that I propose to remove the dependency to
react-dom
in favour of a more generic implementation. So if I would wish to work with the DOM-Node directly, I should useReactDOM.findDOMNode
myself as the user ofreact-transition-group
.What do you think?
Thank you :)
The text was updated successfully, but these errors were encountered: