Home / Function/ AutoSizeInput() — react Function Reference

AutoSizeInput() — react Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  c7888179_9b91_c305_4113_eda40bc5d70c["AutoSizeInput()"]
  02194688_f76e_9fd1_c1a7_fcc33ebcc5ab["AutoSizeInput.js"]
  c7888179_9b91_c305_4113_eda40bc5d70c -->|defined in| 02194688_f76e_9fd1_c1a7_fcc33ebcc5ab
  style c7888179_9b91_c305_4113_eda40bc5d70c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-devtools-shared/src/devtools/views/Components/NativeStyleEditor/AutoSizeInput.js lines 21–58

export default function AutoSizeInput({
  className,
  onFocus,
  placeholder = '',
  testName,
  value,
  ...rest
}: Props): React.Node {
  // $FlowFixMe[missing-local-annot]
  const onFocusWrapper = event => {
    const input = event.target;
    if (input !== null) {
      input.selectionStart = 0;
      input.selectionEnd = value.length;
    }

    if (typeof onFocus === 'function') {
      onFocus(event);
    }
  };

  const isEmpty = value === '' || value === '""';

  return (
    // $FlowFixMe[cannot-spread-inexact] unsafe rest spread
    <input
      className={[styles.Input, className].join(' ')}
      data-testname={testName}
      onFocus={onFocusWrapper}
      placeholder={placeholder}
      style={{
        width: `calc(${isEmpty ? placeholder.length : value.length}ch + 1px)`,
      }}
      value={isEmpty ? '' : value}
      {...rest}
    />
  );
}

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free