Menu

Failed to construct 'Text': Please use the 'new' operator

Failed to construct 'Text': Please use the 'new' operator, this DOM object constructor cannot be called as a function.

Resolution

We did not import anything Text in the React Component. Hence, component is fail to understand this. Import the Text from the source.

e.g. import { Text } from 'ReactFile.js'

React.createElement: type is invalid -- expected a string

React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

If you are seeing this error that means you are using any element that is either not imported or not getting resolved in your render.

Resolution 1

Check the elements that are being use and their import.

Resolution 2

Change the return statement and try to return without function sign. refere Stackoverflow | React.createElement: type is invalid -- expected a string


Hope this help you to resolve the error.

How to clean node or npm cache?

Using the command cache clean we could clear the node cache. 

npm cache clean --force