Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any way to get Context value in component constructor method in ReactJS

Tags:

reactjs

Is there any way to get and handle a context value in another place except render method like constructor or a custom function that I declared in my component class?

In a way that I know, the consumer tag surrounds the fetch function but, I don't want to handle value in consumer tag.

Any idea?

like image 250
Behnam Azimi Avatar asked May 23 '18 13:05

Behnam Azimi


1 Answers

This is possible, You may use like

constructor(props, context) {
    super(props, context)
 }
like image 96
Avi Avatar answered Sep 21 '22 18:09

Avi