Skip to content

Document how to not use PureRenderMixin for createContainer #193

@johnslemmer

Description

@johnslemmer

Pure render doc has a large note at the bottom that says:

Furthermore, shouldComponentUpdate skips updates for the whole component subtree. Make sure all the children components are also "pure".

People are using createContainer in lots of places and it isn't even clearly documented that you can change the options to not use pure. For instance using pure prevents context changes from filtering down to children if the props or state didn't change that is being passed to createContainer.

For anyone looking for how to do this here is an example of how you can stop using pure when calling createContainer:

import { Meteor } from 'meteor/meteor';
import { createContainer } from 'meteor/react-meteor-data';
import MyPage from '/imports/ui/layouts/MyPage.jsx';

export default createContainer({
  getMeteorData: () => (
    {
      isLoggedIn: !!Meteor.userId(),
    }
  ),
  pure: false,
}, MyPage);

To be honest this just feels a bit clunky. I think I would rather have a createContainer call that looks something like this with an extra options param at the end:

export default createContainer(() => (
    {
      isLoggedIn: !!Meteor.userId(),
    }
), MyPage, { pure: false });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions