¡GoConqr estrena diseño! Cuéntanos qué te parece.

Módulo 17 de 28 · Multimedia

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.

 

Instrucciones

Para avanzar en el curso, envía un intento de este test. Puedes enviarlo después de la última pregunta.

Ir al módulo elegido

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?