-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Learn React with TypeScript
By :

Currently, the Alert
component is pretty inflexible. For example, the alert consumer can’t change the heading or the message. At the moment, the heading or the message needs to be changed within Alert
itself. Props solve this problem, and we will learn about them in this section.
Note
Props is short for properties. The React community often refers to these as props, so we will do so in this book.
The props
parameter is an optional parameter that is passed into a React component. This parameter is an object containing the properties of our choice, allowing a parent component to pass data. The following code snippet shows a props
parameter in a ContactDetails
component:
function ContactDetails(props) { console.log(props.name); console.log(props.email); ... }
The props
parameter contains the name
and email
properties in the preceding code snippet.
Note
The parameter doesn’t have to...