1. Home
  2. Training Library
  3. Programming
  4. Courses
  5. Thinking in React: Static Versions

Prop Types

Developed with



The course is part of this learning path

ReactJS: Zero to Hero
Start course


This module looks at static versions in React, Props, and Mock Components to use when testing an application.

Learning Objectives 

The objectives of this module are to provide you with an understanding of: 

  • How to be able to build a static version of an application 
  • How to use Props in components 
  • How to be able to test Component snapshots and Components with props 
  • How to be able to Mock components when testing 

Intended Audience  

This learning path is aimed at all who wish to learn how to use the ReactJS framework.  

Prerequisites of the Course 

It is essential you understand the face of contemporary web development to attend this course. We insist upon JavaScript experience, along with good HTML and CSS skills. 


We welcome all feedback and suggestions - please contact us at qa.elearningadmin@qa.com to let us know what you think. 


If we are making components that are to be re-used, perhaps across several applications and by several different developers, it's useful if it's clear what a component should receive as props. The PropTypes package, which needs to be imported into any component that wants to use proptypes, supplies this functionality. It helps ensure the correct usage of components by clearly defining what data type a prop should be, and can be even more explicit by specifying the shape of an object passed as a prop. You can see in the code, after adding the import, we specify proptypes for each props in this component. This is done by adding a prop types object to the component, and then specifying the name of the prop and the proptype it should be. So for header text, this is a proptype.string. For the object prop, we have specified its shape and you can see that for the function prop, we are able to specify it's prop type as func. Console warnings are produced if the correct type for a prop was not used, as you can see from the first warning on the browser window. Proptypes can also be used to express if a particular prop has to be supplied or not. We can chain the, dot is required to any prop type declaration, like has been done for the unsupplied proptype of any. This has the effect of producing a console warning if the prop is not available and you can see this in the second warning, in the console window. Overall, proptypes can make components easier to read and understand. Some argue that, used correctly, proptypes can negate the need for typescript when writing React applications. If you start your project using create-react-app, the proptypes package is included in the project by default so you don't need to download and install it. However, it will only be bundled into your deployment app if you actually use it. If you didn't use create-react-app to start your project, proptypes is an MPM package that can be easily added. More detailed information on proptypes can be found in the official React documentation. So now you have all the knowledge you need to be able to create a fully static version of an application.


About the Author
Learning paths6

An outstanding trainer in software development with more than 15 years experience as a Corporate and Apprentice Trainer, ICT Teacher and Head of Department, with a passion for technology and its uses. Continuing to develop existing and new skills and courses, primarily in web design using PHP, JavaScript, HTML, CSS and SQL but also OOP (Java), programming foundations (Using Python), DevOps (Git, CI/CD, etc) and Agile/Scrum. Practically minded, a quick learner and a problem solver with an attention to detail to ensure high quality outcomes.

Covered Topics