MCPcopy Index your code
hub / github.com/JedWatson/react-select / constructor

Method constructor

packages/react-select/src/Select.tsx:686–704  ·  view source on GitHub ↗
(props: Props<Option, IsMulti, Group>)

Source from the content-addressed store, hash-verified

684 // ------------------------------
685
686 constructor(props: Props<Option, IsMulti, Group>) {
687 super(props);
688 this.state.instancePrefix =
689 'react-select-' + (this.props.instanceId || ++instanceId);
690 this.state.selectValue = cleanValue(props.value);
691 // Set focusedOption if menuIsOpen is set on init (e.g. defaultMenuIsOpen)
692 if (props.menuIsOpen && this.state.selectValue.length) {
693 const focusableOptionsWithIds: FocusableOptionWithId<Option>[] =
694 this.getFocusableOptionsWithIds();
695 const focusableOptions = this.buildFocusableOptions();
696 const optionIndex = focusableOptions.indexOf(this.state.selectValue[0]);
697 this.state.focusableOptionsWithIds = focusableOptionsWithIds;
698 this.state.focusedOption = focusableOptions[optionIndex];
699 this.state.focusedOptionId = getFocusedOptionId(
700 focusableOptionsWithIds,
701 focusableOptions[optionIndex]
702 );
703 }
704 }
705
706 static getDerivedStateFromProps(
707 props: Props<unknown, boolean, GroupBase<unknown>>,

Callers

nothing calls this directly

Calls 2

cleanValueFunction · 0.90
getFocusedOptionIdFunction · 0.85

Tested by

no test coverage detected