ReactFiberTreeContext.js — react Source File
Architecture documentation for ReactFiberTreeContext.js, a javascript file in the react codebase. 5 imports, 8 dependents.
Entity Profile
Dependency Diagram
graph LR bcb1d0d7_8aa0_fc08_efc9_136215e5b3a1["ReactFiberTreeContext.js"] 4bc7109f_638d_d9f7_bf47_6ec55b2fa128["ReactFiberHydrationContext.js"] bcb1d0d7_8aa0_fc08_efc9_136215e5b3a1 --> 4bc7109f_638d_d9f7_bf47_6ec55b2fa128 dae8f65a_04a5_194b_7c97_c4819e519207["getIsHydrating"] bcb1d0d7_8aa0_fc08_efc9_136215e5b3a1 --> dae8f65a_04a5_194b_7c97_c4819e519207 9a9d2e95_7795_7f3d_d4b6_50cacf2ab78a["clz32.js"] bcb1d0d7_8aa0_fc08_efc9_136215e5b3a1 --> 9a9d2e95_7795_7f3d_d4b6_50cacf2ab78a 6773f9a2_fdb7_4938_741f_4887273ad469["ReactFiberFlags.js"] bcb1d0d7_8aa0_fc08_efc9_136215e5b3a1 --> 6773f9a2_fdb7_4938_741f_4887273ad469 42892443_e223_3da0_aeb9_e1b32a408fb0["ReactInternalTypes"] bcb1d0d7_8aa0_fc08_efc9_136215e5b3a1 --> 42892443_e223_3da0_aeb9_e1b32a408fb0 8a694f3e_c887_fb18_4515_e3e4488bb43e["ReactChildFiber.js"] 8a694f3e_c887_fb18_4515_e3e4488bb43e --> bcb1d0d7_8aa0_fc08_efc9_136215e5b3a1 6d56a395_c0fc_55d6_55fd_16373ba2eeee["ReactFiberActivityComponent.js"] 6d56a395_c0fc_55d6_55fd_16373ba2eeee --> bcb1d0d7_8aa0_fc08_efc9_136215e5b3a1 0be70812_cc0c_b210_f84f_8e61dd5f831c["ReactFiberBeginWork.js"] 0be70812_cc0c_b210_f84f_8e61dd5f831c --> bcb1d0d7_8aa0_fc08_efc9_136215e5b3a1 6b05669d_2f09_63a5_e79f_0afc195f25a3["ReactFiberCompleteWork.js"] 6b05669d_2f09_63a5_e79f_0afc195f25a3 --> bcb1d0d7_8aa0_fc08_efc9_136215e5b3a1 85d2c68c_7609_2c66_22fb_5f02e8a2e8fe["ReactFiberHooks.js"] 85d2c68c_7609_2c66_22fb_5f02e8a2e8fe --> bcb1d0d7_8aa0_fc08_efc9_136215e5b3a1 4bc7109f_638d_d9f7_bf47_6ec55b2fa128["ReactFiberHydrationContext.js"] 4bc7109f_638d_d9f7_bf47_6ec55b2fa128 --> bcb1d0d7_8aa0_fc08_efc9_136215e5b3a1 24334744_4c44_225b_6923_5be11133f949["ReactFiberSuspenseComponent.js"] 24334744_4c44_225b_6923_5be11133f949 --> bcb1d0d7_8aa0_fc08_efc9_136215e5b3a1 53e7e9e3_9e8c_648e_1f4e_0fdfa5c5cb8f["ReactFiberUnwindWork.js"] 53e7e9e3_9e8c_648e_1f4e_0fdfa5c5cb8f --> bcb1d0d7_8aa0_fc08_efc9_136215e5b3a1 style bcb1d0d7_8aa0_fc08_efc9_136215e5b3a1 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.
*
* @flow
*/
// Ids are base 32 strings whose binary representation corresponds to the
// position of a node in a tree.
// Every time the tree forks into multiple children, we add additional bits to
// the left of the sequence that represent the position of the child within the
// current level of children.
//
// 00101 00010001011010101
// ╰─┬─╯ ╰───────┬───────╯
// Fork 5 of 20 Parent id
//
// The leading 0s are important. In the above example, you only need 3 bits to
// represent slot 5. However, you need 5 bits to represent all the forks at
// the current level, so we must account for the empty bits at the end.
//
// For this same reason, slots are 1-indexed instead of 0-indexed. Otherwise,
// the zeroth id at a level would be indistinguishable from its parent.
//
// If a node has only one child, and does not materialize an id (i.e. does not
// contain a useId hook), then we don't need to allocate any space in the
// sequence. It's treated as a transparent indirection. For example, these two
// trees produce the same ids:
//
// <> <>
// <Indirection> <A />
// <A /> <B />
// </Indirection> </>
// <B />
// </>
//
// However, we cannot skip any node that materializes an id. Otherwise, a parent
// id that does not fork would be indistinguishable from its child id. For
// example, this tree does not fork, but the parent and child must have
// different ids.
//
// <Parent>
// <Child />
// </Parent>
//
// To handle this scenario, every time we materialize an id, we allocate a
// new level with a single slot. You can think of this as a fork with only one
// prong, or an array of children with length 1.
//
// It's possible for the size of the sequence to exceed 32 bits, the max
// size for bitwise operations. When this happens, we make more room by
// converting the right part of the id to a string and storing it in an overflow
// variable. We use a base 32 string representation, because 32 is the largest
// power of 2 that is supported by toString(). We want the base to be large so
// that the resulting ids are compact, and we want the base to be a power of 2
// because every log2(base) bits corresponds to a single character, i.e. every
// log2(32) = 5 bits. That means we can lop bits off the end 5 at a time without
// ... (230 more lines)
Domain
Dependencies
- ReactFiberFlags.js
- ReactFiberHydrationContext.js
- ReactInternalTypes
- clz32.js
- getIsHydrating
Imported By
- packages/react-reconciler/src/ReactChildFiber.js
- packages/react-reconciler/src/ReactFiberActivityComponent.js
- packages/react-reconciler/src/ReactFiberBeginWork.js
- packages/react-reconciler/src/ReactFiberCompleteWork.js
- packages/react-reconciler/src/ReactFiberHooks.js
- packages/react-reconciler/src/ReactFiberHydrationContext.js
- packages/react-reconciler/src/ReactFiberSuspenseComponent.js
- packages/react-reconciler/src/ReactFiberUnwindWork.js
Source
Frequently Asked Questions
What does ReactFiberTreeContext.js do?
ReactFiberTreeContext.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain.
What does ReactFiberTreeContext.js depend on?
ReactFiberTreeContext.js imports 5 module(s): ReactFiberFlags.js, ReactFiberHydrationContext.js, ReactInternalTypes, clz32.js, getIsHydrating.
What files import ReactFiberTreeContext.js?
ReactFiberTreeContext.js is imported by 8 file(s): ReactChildFiber.js, ReactFiberActivityComponent.js, ReactFiberBeginWork.js, ReactFiberCompleteWork.js, ReactFiberHooks.js, ReactFiberHydrationContext.js, ReactFiberSuspenseComponent.js, ReactFiberUnwindWork.js.
Where is ReactFiberTreeContext.js in the architecture?
ReactFiberTreeContext.js is located at packages/react-reconciler/src/ReactFiberTreeContext.js (domain: BabelCompiler, directory: packages/react-reconciler/src).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free