ReactMemo.js — react Source File
Architecture documentation for ReactMemo.js, a javascript file in the react codebase. 1 imports, 5 dependents.
Entity Profile
Dependency Diagram
graph LR 10fb6254_a8ad_349b_1871_5b42ca23a8f6["ReactMemo.js"] e1e1de60_2be4_0643_45fb_e2c306735427["ReactSymbols"] 10fb6254_a8ad_349b_1871_5b42ca23a8f6 --> e1e1de60_2be4_0643_45fb_e2c306735427 ffdf54f0_7e34_f1e9_1504_9dbadb0fbac5["ReactClient.js"] ffdf54f0_7e34_f1e9_1504_9dbadb0fbac5 --> 10fb6254_a8ad_349b_1871_5b42ca23a8f6 a893f937_cfbc_33f8_94ec_23cb5000691e["ReactServer.experimental.development.js"] a893f937_cfbc_33f8_94ec_23cb5000691e --> 10fb6254_a8ad_349b_1871_5b42ca23a8f6 8510e4c8_924c_b1b8_d0a0_11cb99b570c0["ReactServer.experimental.js"] 8510e4c8_924c_b1b8_d0a0_11cb99b570c0 --> 10fb6254_a8ad_349b_1871_5b42ca23a8f6 6274036e_add3_9702_84fb_266b97b7660a["ReactServer.fb.js"] 6274036e_add3_9702_84fb_266b97b7660a --> 10fb6254_a8ad_349b_1871_5b42ca23a8f6 a86f40a1_cfab_7bca_7368_f11f9ee52c80["ReactServer.js"] a86f40a1_cfab_7bca_7368_f11f9ee52c80 --> 10fb6254_a8ad_349b_1871_5b42ca23a8f6 style 10fb6254_a8ad_349b_1871_5b42ca23a8f6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @noflow
*/
import {REACT_MEMO_TYPE} from 'shared/ReactSymbols';
export function memo<Props>(
type: React$ElementType,
compare?: (oldProps: Props, newProps: Props) => boolean,
) {
if (__DEV__) {
if (type == null) {
console.error(
'memo: The first argument must be a component. Instead ' +
'received: %s',
type === null ? 'null' : typeof type,
);
}
}
const elementType = {
$$typeof: REACT_MEMO_TYPE,
type,
compare: compare === undefined ? null : compare,
};
if (__DEV__) {
let ownName;
Object.defineProperty(elementType, 'displayName', {
enumerable: false,
configurable: true,
get: function () {
return ownName;
},
set: function (name) {
ownName = name;
// The inner component shouldn't inherit this display name in most cases,
// because the component may be used elsewhere.
// But it's nice for anonymous functions to inherit the name,
// so that our component-stack generation logic will display their frames.
// An anonymous function generally suggests a pattern like:
// React.memo((props) => {...});
// This kind of inner function is not used elsewhere so the side effect is okay.
if (!type.name && !type.displayName) {
Object.defineProperty(type, 'name', {
value: name,
});
type.displayName = name;
}
},
});
}
return elementType;
}
Domain
Dependencies
- ReactSymbols
Imported By
Source
Frequently Asked Questions
What does ReactMemo.js do?
ReactMemo.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain.
What does ReactMemo.js depend on?
ReactMemo.js imports 1 module(s): ReactSymbols.
What files import ReactMemo.js?
ReactMemo.js is imported by 5 file(s): ReactClient.js, ReactServer.experimental.development.js, ReactServer.experimental.js, ReactServer.fb.js, ReactServer.js.
Where is ReactMemo.js in the architecture?
ReactMemo.js is located at packages/react/src/ReactMemo.js (domain: BabelCompiler, directory: packages/react/src).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free