MENU
Class.contextType
An alternative way to provide a context to a component is by assigning .contextType to the class.
RESETRUNFULL
const MyContext = React.createContext("Ali");class Demo extends React.Component {
render() {
return (<h1>Hello, {this.context}.</h1>);
}}Demo.contextType = MyContext;ReactDOM.render(<Demo />, document.querySelector("div"));