Home / File/ error.invalid-mutate-context-in-callback.js — react Source File

error.invalid-mutate-context-in-callback.js — react Source File

Architecture documentation for error.invalid-mutate-context-in-callback.js, a javascript file in the react codebase.

Entity Profile

Relationship Graph

Source Code

function Component(props) {
  const FooContext = useContext(Foo);
  // This function should be memoized, but its mutable range is entangled
  // with the useContext call. We can't memoize hooks, therefore the
  // reactive scope around the hook + callback is pruned and we're left
  // w no memoization of the callback.
  //
  // Ideally we'd determine that this isn't called during render and can
  // therefore be considered "immutable" or otherwise safe to memoize
  // independently
  const onClick = () => {
    FooContext.current = true;
  };
  return <div onClick={onClick} />;
}

Subdomains

Functions

Frequently Asked Questions

What does error.invalid-mutate-context-in-callback.js do?
error.invalid-mutate-context-in-callback.js is a source file in the react codebase, written in javascript. It belongs to the TestingUtilities domain, Fixtures subdomain.
What functions are defined in error.invalid-mutate-context-in-callback.js?
error.invalid-mutate-context-in-callback.js defines 1 function(s): Component.
Where is error.invalid-mutate-context-in-callback.js in the architecture?
error.invalid-mutate-context-in-callback.js is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-mutate-context-in-callback.js (domain: TestingUtilities, subdomain: Fixtures, directory: compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free