Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VB:: React Context API: .createContext is not a function error #129

Closed
IvanChiurcci opened this issue Jul 2, 2018 · 7 comments

Comments

@IvanChiurcci
Copy link

commented Jul 2, 2018

Problem Description

I want to use the new Context API (introduced with React v16.3.0) but receiving this error:
Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_0_react___default.a.createContext is not a function

My project dependencies are these:

"dependencies": { "divi-scripts": "1.0.0", "react": "^16.4.0", "react-dom": "^16.4.0" }

As you see, I am using v16.4.0 of both react and react-dom so it should not throw this error.

I've tested createContext with another React project(not Divi module) with these dependences:

"dependencies": { "react": "^16.3.2", "react-dom": "^16.3.2", "react-scripts": "1.1.4" }

And it worked just fine.

Am I missing something?

Thanks.

Steps To Reproduce

  1. Create context for eg. in Divi module's main component file after all imports (or in a separate file):

const MyContext = React.createContext();

@IvanChiurcci IvanChiurcci changed the title Not possible to use the new React Context API: .createContext is not a function ERROR VB:: React Context API: .createContext is not a function error Jul 2, 2018

@jcdotnet

This comment has been minimized.

Copy link

commented Jul 2, 2018

Same happens with React.createRef

@elegantthemes elegantthemes deleted a comment from etstaging Jul 2, 2018

@IvanChiurcci

This comment has been minimized.

Copy link
Author

commented Jul 4, 2018

Hopefully we will get a response to this issue from ET team soon as this is one of those issues that do not let me finish my module.

@lots0logs

This comment has been minimized.

Copy link
Member

commented Jul 5, 2018

We're currently running React 16.2. Context API was introduced in 16.3. We'll be updating to latest React some time in the next month-ish.

@lots0logs lots0logs closed this Jul 5, 2018

@IvanChiurcci

This comment has been minimized.

Copy link
Author

commented Jul 5, 2018

Thank you Dustin.
Yes, I know that Divi currently uses React v16.2.0 but I thought it should work in development since divi-extension uses React v16.4.0(in my case).
I've just checked the React version in console and it indeed shows 16.2.0, so the divi-extension React version is being ignored. I didn't know that.

@imteyazash

This comment has been minimized.

Copy link

commented Apr 26, 2019

I was facing the same issue but after react and react-dom version changed to @16.8.6 its worked Fine,

@imteyazash

This comment has been minimized.

Copy link

commented Apr 26, 2019

Thanks @IvanChiurcci your solution helped me.Great

@imteyazash

This comment has been minimized.

Copy link

commented Apr 26, 2019

Problem Description

I want to use the new Context API (introduced with React v16.3.0) but receiving this error:
Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_0_react___default.a.createContext is not a function

My project dependencies are these:

"dependencies": { "divi-scripts": "1.0.0", "react": "^16.4.0", "react-dom": "^16.4.0" }

As you see, I am using v16.4.0 of both react and react-dom so it should not throw this error.

I've tested createContext with another React project(not Divi module) with these dependences:

"dependencies": { "react": "^16.3.2", "react-dom": "^16.3.2", "react-scripts": "1.1.4" }

And it worked just fine.

Am I missing something?

Thanks.

Steps To Reproduce

  1. Create context for eg. in Divi module's main component file after all imports (or in a separate file):

const MyContext = React.createContext();

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.