Files
react.dev/examples/context/consumer-inline-function-as-a-child.js
2018-03-29 09:15:30 -07:00

16 lines
369 B
JavaScript

class Example extends React.Component {
render() {
// The inline function will be called when the context value changes,
// And when the props value changes!
return (
<Ctx.Consumer>
{value => (
<div>
Context value:{value}. Props value:{this.props.counter}
</div>
)}
</Ctx.Consumer>
);
}
}