How it works...
In step 3, we defined the Notification component. This component receives three parameters: a flag to automatically hide the component after a few seconds, the message that we want to display, and a callback function that will be executed when the notification gets closed.
When the onClose callback gets executed, we will toggle the notify property to remove the Notification instance and clear the memory.
In step 4, we defined the JSX to render the components of our app. It's important to render the Notification component after the others so that the component will appear on top of all other components.
In step 6, we defined the state of our component. The defaultProps object sets the default values for each property. These ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access