An example on passing props to React components.
Props are things that are passed to a React component. Props can be JavaScript values, functions, objects, and JSX components (single, nested component with children, etc).
Since we are using TypeScript in this project, we have 2 ways to define prop types:
- Use
PropTypes
from theprop-types
package. - Use TypeScript to define the prop type. We will use this approach to define the prop types.
-
Run the application.
npm install npm start
-
Navigate to http://localhost:3000.
- Image courtesy of Pixabay, copyright Susan Cipriano, licensed under Pixabay public domain content license.