Function Props
Learn about the function props for the question list component of our app.
We'll cover the following
Props can consist of primitive types, such as the boolean showContent
prop we implemented in the Question
component. Props can also be objects and arrays, as we have seen with the Question
and QuestionList
components. This in itself is powerful. However, props can also be functions, which allows us to implement components that are extremely flexible.
Steps to implement function prop
Using the following steps, we are going to implement a function prop on the QuestionList
component that allows the consumer to render the question as an alternative to QuestionList
rendering it:
In
QuestionList.tsx
, add arenderItem
function prop to theProps
interface, as follows:
Get hands-on with 1400+ tech skills courses.