GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Modul 17 von 28 · Medien

Using Prop Types

Kostas Diakogiannis

Using Prop Types

Using Prop Types within a component

Then in order to use it, you select the component and you set it's props to the type you want them to have. The types can be string, bool, object, number etc. Additionally you can specify if a property will be mandatory on instantiation of the component or not (required or optional) as it is shown above. ​​​

By taking a look at our example above with the heading, the prop paragraphText not only must be there, anytime we create a MyHeading instance, but also must be of a type string. 

The propTypes object, when attached to a component, contains the component's props as keys, and a number of pre-defined requirements as values.

 

Anleitung

Um im Kurs weiterzukommen, sende einen Versuch dieses Quiz ab. Du kannst ihn nach der letzten Frage absenden.

Zum gewählten Modul

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck