Function Props

Learn about the function props for the question list component of our app.

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:

  1. In QuestionList.tsx, add a renderItem function prop to the Props interface, as follows:

Get hands-on with 1200+ tech skills courses.