Thanks @nazarposhta. I can get the myCount flowing through the props and into the pure component, but not myValue. I have tried all permutations
import React, {Component} from 'react';
import {createContainer} from 'meteor/react-meteor-data';
import Scenes from '../imports/collections/scene.js';
export default class StateHolder extends Component {
constructor() {
super();
this.state = {myCount: 1};
}
incrementCount() {
this.setState({myCount: this.state.myCount + 1});
}
decrementCount() {
this.setState({myCount: this.state.myCount - 1});
}
render() {
return <Container myCount={this.state.myCount} incClick={this.incrementCount.bind(this)} decClick={this.decrementCount.bind(this)}/>;
}
}
// Child component, renders only
class PureComponent extends Component {
//console.log(myValue);
render() {
return (
<div>
Number {this.props.myCount}
<button onClick={this.props.incClick}> Inc </button> <button onClick={this.props.decClick}> Dec </button>
</div>
);
}
}
// Decorated child container.
// Make sure to use this one in parent component's render() function!
let Container = createContainer((props) => {
console.log(props.myCount)
let doc = Scenes.find({scene_no: props.myCount}).fetch;
return {
myValue: doc ? doc.someValue : null
}
}, PureComponent);