Home / Function/ NewRow() — react Function Reference

NewRow() — react Function Reference

Architecture documentation for the NewRow() function in StyleEditor.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  d3ba6293_6d23_a08f_959b_519267ca6e07["NewRow()"]
  a7173e0c_ba07_009a_1ada_f864062596b5["StyleEditor.js"]
  d3ba6293_6d23_a08f_959b_519267ca6e07 -->|defined in| a7173e0c_ba07_009a_1ada_f864062596b5
  style d3ba6293_6d23_a08f_959b_519267ca6e07 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-devtools-shared/src/devtools/views/Components/NativeStyleEditor/StyleEditor.js lines 108–145

function NewRow({changeAttribute, changeValue, validAttributes}: NewRowProps) {
  const [key, setKey] = useState<number>(0);
  const reset = () => setKey(key + 1);

  const newAttributeRef = useRef<string>('');

  const changeAttributeWrapper = (
    oldAttribute: string,
    newAttribute: string,
    value: any,
  ) => {
    // Ignore attribute changes until a value has been specified
    newAttributeRef.current = newAttribute;
  };

  const changeValueWrapper = (attribute: string, value: any) => {
    // Blur events should reset/cancel if there's no value or no attribute
    if (newAttributeRef.current !== '') {
      if (value !== '') {
        changeValue(newAttributeRef.current, value);
      }
      reset();
    }
  };

  return (
    <Row
      key={key}
      attribute={''}
      attributePlaceholder="attribute"
      changeAttribute={changeAttributeWrapper}
      changeValue={changeValueWrapper}
      validAttributes={validAttributes}
      value={''}
      valuePlaceholder="value"
    />
  );
}

Domain

Subdomains

Frequently Asked Questions

What does NewRow() do?
NewRow() is a function in the react codebase, defined in packages/react-devtools-shared/src/devtools/views/Components/NativeStyleEditor/StyleEditor.js.
Where is NewRow() defined?
NewRow() is defined in packages/react-devtools-shared/src/devtools/views/Components/NativeStyleEditor/StyleEditor.js at line 108.

Analyze Your Own Codebase

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

Try Supermodel Free