mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-22 11:52:00 +00:00
16 lines
368 B
JavaScript
16 lines
368 B
JavaScript
class Example extends React.Component {
|
|
// This method will be called when the context value changes,
|
|
// But not when the props value changes!
|
|
renderValue = value => {
|
|
return (
|
|
<div>
|
|
Context value:{value}. Props value:{this.props.counter}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
render() {
|
|
return <Ctx.Consumer>{this.renderValue}</Ctx.Consumer>;
|
|
}
|
|
}
|