The component created with createContainer is a simple wrapper around your actual component, but it is effective in that it handles Meteor reactivity for you, so you don’t have to think about how to keep everything in the know when your data changes (e.g. , subscription downloads, changes ReactiveVar / Session var)
The React component is basically just a JavaScript function, it is called with many arguments (attributes) and creates an output. React does not know if your data has changed unless you say so. A component created using createContainer will re-render when your reactive data changes and sends a new set of details to your actual component.
Parameters for createContainer is a function that returns the reactive data you need and the component that you want to wrap. It is very simple, and the render function for createContainer is literally one line:
return <Component {...this.props} {...this.data} />;
It goes through any details that you pass to the wrapped component, plus it adds a source of reactive information that you configured.
You can see the code here: https://github.com/meteor/react-packages/blob/devel/packages/react-meteor-data/createContainer.jsx
The syntax <Component {...this.props} is known as a sign and basically rotates:
{ prop1: 'some value', prop2: 'another value' }
in
<Component prop1='some value' prop2='another value />
(See: https://facebook.imtqy.com/react/docs/jsx-spread.html )
Michael mason
source share