Hide it, but not unmount it.
npm install react-no-unmount-hide> A react component that hide it's children and not umount them. No more other tag is inserted.
We often do this:
``js
class Bar extends React.Compoent { ... }
class Foo extends React.Component {
constructor() {
super();
this.state = {
value: true,
};
}
render() {
return (
If we do this, the
will be unmount because of this.state.value is false.
When this.state.value is true, the will be mount again. It needs through a series of life cycle.
Sometimes, We just want to hide , not unmount it. So react-no-unmount-hide can DRY for you!!Install
`bash
npm install --save react-no-unmount-hide
`Usage
`js
import ReactNoUnmountHide from 'react-no-unmount-hide';class Demo extends React.Component {
constructor() {
super();
this.state = {
value: false,
haha: 'haha'
};
}
render() {
return (
);
}
}class Sub extends React.Component {
render() {
return (
{this.props.haha}
)
}
}ReactDOM.render(
,
document.getElementById('demo')
);
``