Categories
React Answers

How to fix React JSX file giving error “Cannot read property ‘createElement’ of undefined” error?

Spread the love

Sometimes, we want to fix React JSX file giving error "Cannot read property ‘createElement’ of undefined" error.

In this article, we’ll look at how to fix React JSX file giving error "Cannot read property ‘createElement’ of undefined" error.

How to fix React JSX file giving error "Cannot read property ‘createElement’ of undefined" error?

To fix React JSX file giving error "Cannot read property ‘createElement’ of undefined" error, we need to import React in our JSX file.

For instance, we write

import * as React from 'react';

to import the 'react' module as React.

Then then error will go away.

Conclusion

To fix React JSX file giving error "Cannot read property ‘createElement’ of undefined" error, we need to import React in our JSX file.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *