This code sets a default value for the text prop in the Button component. If no text prop is provided when using the component, it will default to "Click me". This helps avoid undefined values and makes the component more user-friendly.
const Button = ({ text = "Click me" }) => <button>{text}</button>;
You Might Also Like
Using useMemo for Caching and Optimizing Performance
~~`useMemo`~~ is a React Hook that helps optimize performance by memoizing (caching) the result of a...
Destructuring Props in Functional Components
When you pass any props to any componenet, as in this example passing name and age as props to Profi...