{"record":{"id":"4d4ca0eab9bbca39","repo":"oxc-project/oxc","slug":"do-not-define-components-during-render","errorCode":null,"errorMessage":"Do not define components during render.","messagePattern":"Do not define components during render\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/react/no_unstable_nested_components.rs","lineNumber":43,"sourceCode":"};\n\nconst COMPONENT_AS_PROPS_INFO: &str =\n    \" If you want to allow component creation in props, set `allowAsProps` option to true.\";\n\nfn no_unstable_nested_components_diagnostic(\n    span: Span,\n    parent_name: Option<&str>,\n    is_component_in_prop: bool,\n) -> OxcDiagnostic {\n    let parent = parent_name.map_or(String::new(), |name| format!(\" `{name}`\"));\n    let mut help = format!(\n        \"Move this component definition out of the parent component{parent} and pass data as props.\"\n    );\n    if is_component_in_prop {\n        help.push_str(COMPONENT_AS_PROPS_INFO);\n    }\n\n    OxcDiagnostic::warn(\"Do not define components during render.\").with_help(help).with_label(span)\n}\n\n#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\nstruct NoUnstableNestedComponentsConfig {\n    /// Allow component definitions in props.\n    allow_as_props: bool,\n    /// Optional custom propTypes validators accepted for eslint-plugin-react compatibility.\n    custom_validators: Vec<CompactStr>,\n    /// Glob pattern for render-prop names that may receive inline component definitions.\n    prop_name_pattern: CompactStr,\n}\n\nimpl Default for NoUnstableNestedComponentsConfig {\n    fn default() -> Self {\n        Self {\n            allow_as_props: false,\n            custom_validators: Vec::new(),","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/oxc-project/oxc/blob/a3d33dda7cb69da23db4fcaa2c0c05de61e760a1/crates/oxc_linter/src/rules/react/no_unstable_nested_components.rs#L25-L61","documentation":"Emitted by report_candidate in the react no-unstable-nested-components rule when a component definition is created during another component's render — inside the parent's body, a render callback, or (when flagged) a props position. Creating components during render remounts them every render, resetting state and hurting performance.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/no_unstable_nested_components.rs:43 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Move the nested component definition outside the parent component and pass data via props","If the definition is intentionally inline inside props, set the allowAsProps option to true"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a3d33dda7cb69da23db4fcaa2c0c05de61e760a1","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}