{"record":{"id":"f0692e2916727ae3","repo":"oxc-project/oxc","slug":"style-prop-value-must-be-an-object","errorCode":null,"errorMessage":"`style` prop value must be an object.","messagePattern":"`style` prop value must be an object\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/react/style_prop_object.rs","lineNumber":24,"sourceCode":"    },\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\nuse oxc_str::CompactStr;\nuse schemars::JsonSchema;\nuse serde::Deserialize;\n\nuse crate::{\n    AstNode,\n    ast_util::get_declaration_of_variable,\n    context::{ContextHost, LintContext},\n    rule::{DefaultRuleConfig, Rule},\n    utils::is_create_element_call,\n};\n\nfn style_prop_object_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"`style` prop value must be an object.\").with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct StylePropObject(Box<StylePropObjectConfig>);\n\n#[derive(Debug, Default, Clone, JsonSchema, Deserialize)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct StylePropObjectConfig {\n    /// List of component names on which to allow `style` prop values of any type.\n    allow: Vec<CompactStr>,\n}\n\nimpl std::ops::Deref for StylePropObject {\n    type Target = StylePropObjectConfig;\n\n    fn deref(&self) -> &Self::Target {\n        &self.0\n    }","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/react/style_prop_object.rs#L6-L42","documentation":"Raised by react/style_prop_object when the `style` prop on a JSX element or createElement call is not an object expression — e.g. a string like `style=\"color:red\"` or an identifier that resolves to a non-object. At the throw site React requires style to be an object of CSS properties; string styles (an HTML habit) are rejected at runtime with a warning, so the code is broken as written. run() validates the style prop's expression (following variable declarations via get_declaration_of_variable) and reports non-object values.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/style_prop_object.rs:24 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Convert the string to a style object: style={{ marginTop: 10 }}.","For raw CSS strings, use a class or a library that accepts strings (e.g. styled-components)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}