NewArrayValue.js — react Source File
Architecture documentation for NewArrayValue.js, a javascript file in the react codebase. 9 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR bb770434_43dc_71aa_77ec_098236a83413["NewArrayValue.js"] bba85af0_a356_d0c5_4d12_914508b89593["store.js"] bb770434_43dc_71aa_77ec_098236a83413 --> bba85af0_a356_d0c5_4d12_914508b89593 04e82e8f_4cf5_68df_3f32_fe28fb509921["EditableName.js"] bb770434_43dc_71aa_77ec_098236a83413 --> 04e82e8f_4cf5_68df_3f32_fe28fb509921 ca8114b4_a39e_775f_8cfb_ea560d8ed77f["EditableName"] bb770434_43dc_71aa_77ec_098236a83413 --> ca8114b4_a39e_775f_8cfb_ea560d8ed77f fa31bba5_57ed_1039_52bb_4a8cb4382642["utils.js"] bb770434_43dc_71aa_77ec_098236a83413 --> fa31bba5_57ed_1039_52bb_4a8cb4382642 7a30ca2b_8808_58b2_56bc_12441f27a1e1["utils.js"] bb770434_43dc_71aa_77ec_098236a83413 --> 7a30ca2b_8808_58b2_56bc_12441f27a1e1 d8005929_71e8_5244_3e56_2c28c050aee9["NewArrayValue.css"] bb770434_43dc_71aa_77ec_098236a83413 --> d8005929_71e8_5244_3e56_2c28c050aee9 ac587885_e294_a1e9_b13f_5e7b920fdb42["react"] bb770434_43dc_71aa_77ec_098236a83413 --> ac587885_e294_a1e9_b13f_5e7b920fdb42 aec7978f_0a19_ba93_de9e_ac8cf5ddc74b["types"] bb770434_43dc_71aa_77ec_098236a83413 --> aec7978f_0a19_ba93_de9e_ac8cf5ddc74b 4077b620_5c59_61c2_0910_273f565da757["bridge"] bb770434_43dc_71aa_77ec_098236a83413 --> 4077b620_5c59_61c2_0910_273f565da757 276bc34e_3008_101e_3cd7_cc895fcd3848["KeyValue.js"] 276bc34e_3008_101e_3cd7_cc895fcd3848 --> bb770434_43dc_71aa_77ec_098236a83413 style bb770434_43dc_71aa_77ec_098236a83413 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
*/
import * as React from 'react';
import {useState} from 'react';
import Store from '../../store';
import EditableName from './EditableName';
import {smartParse} from '../../utils';
import {parseHookPathForEdit} from './utils';
import styles from './NewArrayValue.css';
import type {InspectedElement} from 'react-devtools-shared/src/frontend/types';
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
type Props = {
bridge: FrontendBridge,
depth: number,
hidden: boolean,
hookID?: ?number,
index: number,
inspectedElement: InspectedElement,
path: Array<string | number>,
store: Store,
type: 'props' | 'context' | 'hooks' | 'state',
};
export default function NewArrayValue({
bridge,
depth,
hidden,
hookID,
index,
inspectedElement,
path,
store,
type,
}: Props): React.Node {
const [key, setKey] = useState<number>(0);
const [isInvalid, setIsInvalid] = useState(false);
// This is a bit of an unusual usage of the EditableName component,
// but otherwise it acts the way we want for a new Array entry.
// $FlowFixMe[missing-local-annot]
const overrideName = (oldPath: any, newPath) => {
const value = newPath[newPath.length - 1];
let parsedValue;
let newIsInvalid = true;
try {
parsedValue = smartParse(value);
newIsInvalid = false;
} catch (error) {}
if (isInvalid !== newIsInvalid) {
setIsInvalid(newIsInvalid);
}
if (!newIsInvalid) {
setKey(key + 1);
const {id} = inspectedElement;
const rendererID = store.getRendererIDForElement(id);
if (rendererID !== null) {
let basePath = path;
if (hookID != null) {
basePath = parseHookPathForEdit(basePath);
}
bridge.send('overrideValueAtPath', {
type,
hookID,
id,
path: [...basePath, index],
rendererID,
value: parsedValue,
});
}
}
};
return (
<div
key={key}
hidden={hidden}
style={{
paddingLeft: `${(depth - 1) * 0.75}rem`,
}}>
<div className={styles.NewArrayValue}>
<EditableName
allowWhiteSpace={true}
autoFocus={key > 0}
className={[styles.EditableName, isInvalid && styles.Invalid].join(
' ',
)}
initialValue=""
overrideName={overrideName}
path={path}
/>
</div>
</div>
);
}
Domain
Subdomains
Functions
Dependencies
Source
Frequently Asked Questions
What does NewArrayValue.js do?
NewArrayValue.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in NewArrayValue.js?
NewArrayValue.js defines 1 function(s): NewArrayValue.
What does NewArrayValue.js depend on?
NewArrayValue.js imports 9 module(s): EditableName, EditableName.js, NewArrayValue.css, bridge, react, store.js, types, utils.js, and 1 more.
What files import NewArrayValue.js?
NewArrayValue.js is imported by 1 file(s): KeyValue.js.
Where is NewArrayValue.js in the architecture?
NewArrayValue.js is located at packages/react-devtools-shared/src/devtools/views/Components/NewArrayValue.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src/devtools/views/Components).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free