mercredi 30 août 2017

Suppress updating of a child components that are connected to redux state

I am making an app using react and redux. I want to stop child components from updating in the parent component, even though they are connected to state independently. shouldComponentUpdate does not prevent this. Is there some way this is possible? Maybe like caching a pre-rendered version of the children? I don't need it to be interactive at all, not even scrolling is required. I just need it to be visually the same.

Code example:

class SomeComponent extends Component {
  constructor() {
    super()
    this.state = { dontReload: false }
  }

  render() {
    return (
      <div>
        <SomeStateConnectedComponent />
      </div>
    )
  }
}

How could I make it so the state connected component does not update if dontReload is true?




Aucun commentaire:

Enregistrer un commentaire