What propType will have from the JSX support in the reaction

In response, you can set propType props, which is included in the component. For one of my details, I want the value to be either zero or a JSX string. React docs do not cover what propType should be used for JSX.

When testing, I found that it would not cause errors when using the propTypes of an object or element. When using another, such as a character, I get an error message that says this is an object. If it were an object, then he should have complained when it is an element.

What is the correct propType for JSX?

+5
source share
2 answers

Try using this propType ...

React.PropTypes.element 
+8
source

PropTypes.node or PropTypes.element can be used

+1
source

Source: https://habr.com/ru/post/1260340/


All Articles