Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-transform-catch-errors does not look like a React component

I'm working on a react project and we are using react starter kit. I am new to the project and when I clone the project from github and start the project using npm start it start the server but in web inspector I get following error.

Uncaught Error: imports[1] for react-transform-catch-errors does not look like a React component.

People who already working in the project doesn't get this error. But when I ask from one friend to get a new clone and do the same thing I did he also got the same error.

I don't know what details need to post so if anybody need more details please ask.

like image 727
Ryxle Avatar asked Jun 18 '16 10:06

Ryxle


People also ask

How do you catch errors in React?

Our class component should also have at least three methods: A static method called getDerivedStateFromError , which is used to update the error boundary's state. A componentDidCatch lifecycle method for performing operations when our error boundaries catch an error, such as logging to an error logging service.

How do you trigger an error boundary React?

With the new feature in React, developers can test the Error Boundaries by a toggle error button, added to the DevTools. When we click on the toggle error button on the component labeled 'Inner Component', Error boundary is triggered.

How do you handle error boundaries in functional components?

In order to use Error Boundary in Functional Component, I use react-error-boundary. When we run this application, we will get a nice error display form the content of ErrorHandler component. React error boundary catches any error from the components below them in the tree.

What is fallback UI in React?

A display of a beautiful UI (HTML and CSS) instead if error when something broke in the code. Example as below. FALLBACK UI SCREEN.


1 Answers

Finally I found the solution... this is due to version mismatch. I don't have a technical explanation. I found three packages in package json related to this problem

"react-transform-catch-errors": "^1.0.0",
"react-transform-hmr": "^1.0.1",
"redbox-react": "^1.1.1",

so what I did was removed the ^ which download the latest version. Also removed already installed node-modules folder and ran npm cache clear.

After that I ran npm install and the issue gone. I'm a happy lad :D

like image 102
Ryxle Avatar answered Sep 20 '22 18:09

Ryxle