This inquiry pertains to the guideline require-default-props.
Here is the code snippet in question:
function MyComponent({
blubb = 'my default',
}: {
blubb?: string,
}) {
// blubb defaults to 'my default'
};
Eslint is flagging an issue with MyComponent.defaultProps
not being properly configured.
I omitted setting it up because the default value is already specified within the function signature (which functions correctly)
Question 1: Why does eslint-plugin-react
mandate defaults to be established under defaultProps rather than how I declared it above?
Question 2: Why is this rule enabled by default? Shouldn't optional parameters actually be... optional? What if my default value is simply... undefined
? Do I have to explicitly define a default value of undefined
when that's already the implicit default?
Your insights are greatly appreciated. <)