December 2019
Intermediate to advanced
598 pages
12h 21m
English
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 experienced in 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.
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:
interface Props { data: QuestionData[]; renderItem?: (item: QuestionData) => JSX.Element;}Read now
Unlock full access