Implementing Component Props
Learn to implement component props.
Components can have properties that allow consumers to pass parameters into them, just like when we pass parameters into a JavaScript function. React function components accept a single parameter named props, which holds its properties. The word props is short for properties.
In this section, we’ll learn all about how to implement strongly typed props, including optional and default props. Then, we’ll implement the rest of the home page to assist in our learning.
Creating HomePage child components
We are going to implement some child components that the HomePage
component will use. We will pass the unanswered questions data to the child components via props.
Creating the QuestionList component
Let’s go through the following steps to implement the QuestionList
component:
Let’s create a file called
QuestionList.tsx
in thesrc
folder and add the following import statements:
Get hands-on with 1400+ tech skills courses.