Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find out which react component throws empty props error

Tags:

reactjs

I am using react v15.1 and it's got this small change where null value props throws the following error:

react warning us of null value

The console log isn't very helpful, what's a better way to find out in which component this null value props is located?

Thank you

like image 384
Nik So Avatar asked May 25 '16 14:05

Nik So


People also ask

How do you find the error in React?

Besides, you can use the static function getDerivedStateFromError(error) to update the state and use the render() method to display a fallback UI if an error occurs. An example error boundary component is shown below. After that, you only need to wrap the required component(s) inside the error boundary component.

How do you check for error boundaries?

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.


1 Answers

Future versions of React will treat as a request to clear the input. However, React 0.14 has been ignoring value={null}. React 15 warns you on a null input value and offers you to clarify your intention. To fix the warning, you may explicitly pass an empty string to clear a controlled input, or pass undefined to make the input uncontrolled. https://facebook.github.io/react/blog/2016/04/07/react-v15.html

Details is here https://github.com/facebook/react/pull/5048/commits

You can either use breakpoint or manually check all components that have input, select or textarea within the page

like image 138
Terry Avatar answered Oct 11 '22 11:10

Terry