Skip to content

Instantly share code, notes, and snippets.

@zachariahtimothy
Created November 30, 2018 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zachariahtimothy/22b091d3735c2308ded0857cf70e141b to your computer and use it in GitHub Desktop.
Save zachariahtimothy/22b091d3735c2308ded0857cf70e141b to your computer and use it in GitHub Desktop.
Access unstated state
class TaylorMade extends React.Component {
myCounter = null;
shouldComponentUpdate() {
if (this.myCounter) {
console.log('Bomb.com, I have a counter!');
}
return true;
}
render() {
return (
<Subscribe to={[CounterContainer}>
{counter => {
this.myCounter = counter;
return (
<div>I am a mossy pig!</div>
);
}
</Subscribe>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment