Posts

Showing posts from February 10, 2019

How to get multiple static contexts in new CONTEXT API in React v16.6

Image
2 Hi I'm trying to access multiple contexts in a component but I got success with only one context value from provider. there are two providers ListContext and `MappingContext. How can I access contexts like this: class TableData extends React.Component { static contextType = ListContext; static contextType = MappingContext; componentDidMount() { const data = this.context // it will have only one context from ListContext } I know I can use multiple providers in render() but I want to access the contexts like above. Any help will be appreciated. Thanks javascript reactjs share | improve this question asked Dec 31 '18 at 13:46