Skip to content

Prefer Hoisted Jsx Object Properties

Suggestion
small-rules/prefer-hoisted-jsx-object-properties

Prefer extracting inline JSX object props to module-level constants when the entire object is statically hoistable.

Diagnostic Messages

hoistableObjectProp
Extract `{{objectText}}` to a module-level const — this inline JSX prop object is fully static and causes unnecessary reference churn on every render.

Configuration

This rule does not accept options.

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/prefer-hoisted-jsx-object-properties": "error"
}
}

Examples

Inline JSX object property
function View() {
return <Component options={{ enabled: true, count: 5 }} />;
}
Hoisted JSX property object
const PROPS = { enabled: true };
const view = <Component options={PROPS} />;