no-object-type-as-default-prop
Added in v0.9.4Configuration
Disallow newly created reference values as default props in function components.
Rule Details
An inline object, array, function, class, constructed value, regular expression,
JSX element, or Symbol() default creates a different value on each render.
Passing it to a memoized child or using it as a hook dependency can cause
unnecessary renders or a render loop. Use a stable reference instead.
The rule checks direct property defaults in the first destructured parameter of
a detected function component. It does not check nested properties, defaults for
the entire parameter, or defaultProps assignments. As in upstream, functions
passed directly to component wrappers such as React.memo and React.forwardRef
are not checked. JSX fragments and calls other than a direct Symbol() call are
outside the rule's checks.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Options
This rule has no options.