DEV Community

mehrzadtejareh
mehrzadtejareh

Posted on

How can I define multiple static contextType in a class component?

hello I wants to know how can I define multiple static ContextType when I need to use more than one context in a class component methods.

export default class Component extends React.Component{
static contextType = MyContext1; //and MyContext2

constructor(props){
    super(props);
}

componentDidMount = () => console.log(this.context); //need Context2

render(){
    return(

Top comments (0)