Problem: Declaring default React prop values inside the component


Problem: Declaring default React prop values inside the component.

Why it's a problem:
🚩"Hides" the API inside the implementation
🚩Makes the component harder to read
🚩 The default isn't documented as part of the public API in tools like Storybook
🚩 Often leads to repeated default logic when the prop is read in multiple places

Solution:
1. Destructure props in the function's signature
2. Declare the default within the destructured props using the default argument syntax.

View original on X