getWriteErrorReason() — react Function Reference
Architecture documentation for the getWriteErrorReason() function in InferMutationAliasingEffects.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD ffdcc9ff_f0d0_148b_1939_2e048f116edf["getWriteErrorReason()"] d24875c3_c045_4414_2cc9_16f96d59c629["InferMutationAliasingEffects.ts"] ffdcc9ff_f0d0_148b_1939_2e048f116edf -->|defined in| d24875c3_c045_4414_2cc9_16f96d59c629 f255dd41_8c48_19a9_1bcc_8efd2d663f32["applySignature()"] f255dd41_8c48_19a9_1bcc_8efd2d663f32 -->|calls| ffdcc9ff_f0d0_148b_1939_2e048f116edf 7cb90dd3_dbe0_0087_670d_277ddeadabfc["applyEffect()"] 7cb90dd3_dbe0_0087_670d_277ddeadabfc -->|calls| ffdcc9ff_f0d0_148b_1939_2e048f116edf style ffdcc9ff_f0d0_148b_1939_2e048f116edf fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/Inference/InferMutationAliasingEffects.ts lines 2786–2810
export function getWriteErrorReason(abstractValue: AbstractValue): string {
if (abstractValue.reason.has(ValueReason.Global)) {
return 'Modifying a variable defined outside a component or hook is not allowed. Consider using an effect';
} else if (abstractValue.reason.has(ValueReason.JsxCaptured)) {
return 'Modifying a value used previously in JSX is not allowed. Consider moving the modification before the JSX';
} else if (abstractValue.reason.has(ValueReason.Context)) {
return `Modifying a value returned from 'useContext()' is not allowed.`;
} else if (abstractValue.reason.has(ValueReason.KnownReturnSignature)) {
return 'Modifying a value returned from a function whose return value should not be mutated';
} else if (abstractValue.reason.has(ValueReason.ReactiveFunctionArgument)) {
return 'Modifying component props or hook arguments is not allowed. Consider using a local variable instead';
} else if (abstractValue.reason.has(ValueReason.State)) {
return "Modifying a value returned from 'useState()', which should not be modified directly. Use the setter function to update instead";
} else if (abstractValue.reason.has(ValueReason.ReducerState)) {
return "Modifying a value returned from 'useReducer()', which should not be modified directly. Use the dispatch function to update instead";
} else if (abstractValue.reason.has(ValueReason.Effect)) {
return 'Modifying a value used previously in an effect function or as an effect dependency is not allowed. Consider moving the modification before calling useEffect()';
} else if (abstractValue.reason.has(ValueReason.HookCaptured)) {
return 'Modifying a value previously passed as an argument to a hook is not allowed. Consider moving the modification before calling the hook';
} else if (abstractValue.reason.has(ValueReason.HookReturn)) {
return 'Modifying a value returned from a hook is not allowed. Consider moving the modification into the hook where the value is constructed';
} else {
return 'This modifies a variable that React considers immutable';
}
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does getWriteErrorReason() do?
getWriteErrorReason() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Inference/InferMutationAliasingEffects.ts.
Where is getWriteErrorReason() defined?
getWriteErrorReason() is defined in compiler/packages/babel-plugin-react-compiler/src/Inference/InferMutationAliasingEffects.ts at line 2786.
What calls getWriteErrorReason()?
getWriteErrorReason() is called by 2 function(s): applyEffect, applySignature.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free