Default Props for Components


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

Custom Hook : Simplify Code with Reusable Logic

Setting up a reusable data-fetching function to simplify API calls and state management. # State In...

Labels: Names used to label loops and control flow

``` outerLoop: for (let i = 0; i < 3; i++) { for (let j = 0; j < 3; j++) { if (j === 1) {...