FriendsStatusDisplay Class — react Architecture
Architecture documentation for the FriendsStatusDisplay class in ReactMultiChildReconcile-test.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD fc75d32a_bb2d_fbb7_775d_b412630ad896["FriendsStatusDisplay"] 89957210_3fe1_9bf6_da04_073d48f2027c["ReactMultiChildReconcile-test.js"] fc75d32a_bb2d_fbb7_775d_b412630ad896 -->|defined in| 89957210_3fe1_9bf6_da04_073d48f2027c 1c672a3c_089e_e501_750b_9ea6362a22ba["getOriginalKeys()"] fc75d32a_bb2d_fbb7_775d_b412630ad896 -->|method| 1c672a3c_089e_e501_750b_9ea6362a22ba d0a9c5e2_aaeb_80eb_adf1_99f3cee39664["getStatusDisplays()"] fc75d32a_bb2d_fbb7_775d_b412630ad896 -->|method| d0a9c5e2_aaeb_80eb_adf1_99f3cee39664 d6d49b3c_fe00_ad2d_2d78_6586c3b09363["verifyPreviousRefsResolved()"] fc75d32a_bb2d_fbb7_775d_b412630ad896 -->|method| d6d49b3c_fe00_ad2d_2d78_6586c3b09363 f17a501d_68c9_42a0_e169_575f7db01a34["render()"] fc75d32a_bb2d_fbb7_775d_b412630ad896 -->|method| f17a501d_68c9_42a0_e169_575f7db01a34
Relationship Graph
Source Code
packages/react-dom/src/__tests__/ReactMultiChildReconcile-test.js lines 63–135
class FriendsStatusDisplay extends React.Component {
displays = {};
/**
* Gets the order directly from each rendered child's `index` field.
* Refs are not maintained in the rendered order, and neither is
* `this._renderedChildren` (surprisingly).
*/
getOriginalKeys() {
const originalKeys = [];
for (const key in this.props.usernameToStatus) {
if (this.props.usernameToStatus[key]) {
originalKeys.push(key);
}
}
return originalKeys;
}
/**
* Retrieves the rendered children in a nice format for comparing to the input
* `this.props.usernameToStatus`.
*/
getStatusDisplays() {
const res = {};
const originalKeys = this.getOriginalKeys();
for (let i = 0; i < originalKeys.length; i++) {
const key = originalKeys[i];
res[key] = this.displays[key];
}
return res;
}
/**
* Verifies that by the time a child is flushed, the refs that appeared
* earlier have already been resolved.
* TODO: This assumption will likely break with incremental reconciler
* but our internal layer API depends on this assumption. We need to change
* it to be more declarative before making ref resolution indeterministic.
*/
verifyPreviousRefsResolved(flushedKey) {
const originalKeys = this.getOriginalKeys();
for (let i = 0; i < originalKeys.length; i++) {
const key = originalKeys[i];
if (key === flushedKey) {
// We are only interested in children up to the current key.
return;
}
expect(this.displays[key]).toBeTruthy();
}
}
render() {
const children = [];
for (const key in this.props.usernameToStatus) {
const status = this.props.usernameToStatus[key];
children.push(
!status ? null : (
<StatusDisplay
key={key}
ref={current => {
this.displays[key] = current;
}}
contentKey={key}
onFlush={this.verifyPreviousRefsResolved.bind(this, key)}
status={status}
/>
),
);
}
const childrenToRender = this.props.prepareChildren(children);
return <div>{childrenToRender}</div>;
}
}
Source
Frequently Asked Questions
What is the FriendsStatusDisplay class?
FriendsStatusDisplay is a class in the react codebase, defined in packages/react-dom/src/__tests__/ReactMultiChildReconcile-test.js.
Where is FriendsStatusDisplay defined?
FriendsStatusDisplay is defined in packages/react-dom/src/__tests__/ReactMultiChildReconcile-test.js at line 63.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free