1

I'm trying to run this React Context example in codesandbox, but getting this error:

Invariant Violation

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

Check the render method of `MyProvider`.

I have React set to 16.3 and the code itself was pulled directly from this Wes Bos example. I've looked over the code a handful of times but I'm not seeing any problems. Could it be a context setting with codesandbox I'm not understanding?

1 Answer 1

3

You'll also have to use a 16.3 version of react-dom. In your sandbox react is 16.3.0 and react-dom is 16.2.0. Here's a sandbox with a working example: https://codesandbox.io/s/1r1j221nl3

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.