Skip to content

No Native Properties Spread

ErrorRoblox
small-rules/no-native-properties-spread

Disallow spreading static property bags into nativeProperties/*NativeProperties props and onto JSX elements via intermediate objects, because the spread creates a new copied table every render.

Diagnostic Messages

noElementSpread
Spreading static property bag {{source}} through an intermediate object creates a new table every render. Inline the full object properties directly on the JSX element.
noNativePropertiesSpread
Spreading static property bag {{source}} into {{prop}} creates a new table every render. Pass it directly or inline the full object instead.

Configuration

This rule does not accept options.

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/no-native-properties-spread": "error"
}
}

Examples

native properties spread
const SOME_CONSTANT = {}; const view = <Frame nativeProperties={{ ...SOME_CONSTANT, Text: "hello" }} />;
direct native properties reference
const view = <Frame nativeProperties={SOME_CONSTANT} />;