jsx-no-leaked-render
Added in v0.5.1Configuration
Rule Details
In React, conditionally rendering content with && is a common pattern, but it can leak unintended values into the DOM when the left-hand side is falsy but not boolean. For example, {count && <Something/>} renders 0 as a literal "0" in React DOM and crashes React Native when count is 0. The same applies to NaN, and in React 17 also to ''.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Options
This rule accepts an options object as its second argument.
validStrategies
Type: Array<"ternary" | "coerce"> Default: ["ternary", "coerce"]
Which conversion strategies count as valid. The first entry of the array is the strategy used for autofix.
ignoreAttributes
Type: boolean Default: false
When true, JSX attribute values are exempt from the check; only the children of JSX elements are inspected. Useful when a downstream component accepts truthy-coerced props.