Rules
no-string-style-prop
Disallows the use of string style prop in JSX. Use an object instead.
Full Name in eslint-plugin-react-dom
react-dom/no-string-style-propFull Name in @eslint-react/eslint-plugin
@eslint-react/dom-no-string-style-propPresets
dom
recommended
strict
Rule Details
Using a string value for the style prop is not valid in React. The style prop must be an object with camelCased CSS properties. This rule helps catch incorrect string usage that would cause runtime errors.
Common Violations
Invalid
function MyComponent() {
return <div style="color: red;" />;
}Valid
function MyComponent() {
return <div style={{ color: "red" }} />;
}Resources
See Also
react-dom/no-unknown-property
Disallows unknownDOMproperties.react-jsx/no-namespace
Enforces the absence of anamespacein React elements.