no-complicated-conditional-rendering (Deprecated)
Rule category
Complexity.
What it does
Prevents complicated conditional rendering in JSX.
Examples
Failing
import React from "react";
interface ExampleProps {
ExampleProps.hideShapes: boolean
hideShapes: boolean;
ExampleProps.debugSvg: boolean
debugSvg: boolean;
}
function function Example({ hideShapes, debugSvg }: ExampleProps): React.JSX.Element
Example({ hideShapes: boolean
hideShapes, debugSvg: boolean
debugSvg }: ExampleProps) {
return (
<JSX.IntrinsicElements.div: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>
div>
{hideShapes: boolean
hideShapes
? null
: debugSvg: boolean
debugSvg
? "<ShapesWithSVGs />"
: "<ShapesToDisplay />"}
</JSX.IntrinsicElements.div: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>
div>
);
}
Passing
import React from "react";
interface ExampleProps {
ExampleProps.hideShapes: boolean
hideShapes: boolean;
ExampleProps.debugSvg: boolean
debugSvg: boolean;
}
function function Example({ hideShapes, debugSvg }: ExampleProps): "<ShapesWithSVGs />" | "<ShapesToDisplay />" | null
Example({ hideShapes: boolean
hideShapes, debugSvg: boolean
debugSvg }: ExampleProps) {
if (hideShapes: boolean
hideShapes) {Early return if nothing to render return null;
}
return debugSvg: boolean
debugSvg ? "<ShapesWithSVGs />" : "<ShapesToDisplay />";
}