React JSX file giving error "Cannot read property 'createElement' of undefined" React JSX file giving error "Cannot read property 'createElement' of undefined" reactjs reactjs

React JSX file giving error "Cannot read property 'createElement' of undefined"


To import React do import React from 'react' You add brackets when the thing you are importing is not the default export in that module or file. In case of react, it's the default export.

This might apply to your other imports depending on how you defined them.


import React, { Component } from 'react'

This worked for me. I'm not sure why it fixed my version of this issue, though. So if you are someone who stumbled upon this problem and you use create-react-app as your starting boilerplate, this way of importing React will do the trick. (as of Oct '18, lol)


For those who are working ReactJS with TypeScript.

import * as React from 'react';