I'm using React's new context api (v16.x).
I made a simple test application to ensure my understanding of it:
const MyContext = React.createContext();
const Child = () => (
<MyContext.Consumer>
{value => value}
</MyContext.Consumer>
)
const Parent = () => (
<MyContext.Provider value={"Working"}>
<Child/>
</MyContext.Provider>
)
This works fine, even with intermediary components between <Parent>
and <Child>
.
However, the component below produces the following error: "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined" (note: I'm using material-ui library)
let NavigationPanel = (props) => (
<DisabledContext.Provider value={props.disabled}>
<InstructionsContext.Provider value={props.onOpenInstructions}>
<Hidden mdUp><DrawerNavigationPanel data={props.data}/></Hidden>
<Hidden smDown><StaticNavigationPanel data={props.data}/></Hidden>
</InstructionsContext.Provider>
</DisabledContext.Provider>
)
Why might this be happening?