MCPcopy Create free account
hub / github.com/downshift-js/downshift / componentDidUpdate

Method componentDidUpdate

src/downshift.js:1169–1203  ·  view source on GitHub ↗
(prevProps, prevState)

Source from the content-addressed store, hash-verified

1167 }
1168
1169 componentDidUpdate(prevProps, prevState) {
1170 if (process.env.NODE_ENV !== 'production') {
1171 validateControlledUnchanged(this.state, prevProps, this.props)
1172 /* istanbul ignore if (react-native) */
1173 if (
1174 !isReactNative &&
1175 this.getMenuProps.called &&
1176 !this.getMenuProps.suppressRefError
1177 ) {
1178 validateGetMenuPropsCalledCorrectly(this._menuNode, this.getMenuProps)
1179 }
1180 }
1181
1182 if (
1183 this.props.selectedItem !== undefined &&
1184 this.props.selectedItemChanged(
1185 prevProps.selectedItem,
1186 this.props.selectedItem,
1187 )
1188 ) {
1189 this.internalSetState({
1190 type: stateChangeTypes.controlledPropUpdatedSelectedItem,
1191 inputValue: this.props.itemToString(this.props.selectedItem),
1192 })
1193 }
1194
1195 if (!this.avoidScrolling && this.shouldScroll(prevState, prevProps)) {
1196 this.scrollHighlightedItemIntoView()
1197 }
1198
1199 /* istanbul ignore else (react-native) */
1200 if (!isReactNative) {
1201 this.updateStatus()
1202 }
1203 }
1204
1205 componentWillUnmount() {
1206 this.cleanup() // avoids memory leak

Callers

nothing calls this directly

Calls 3

shouldScrollMethod · 0.95

Tested by

no test coverage detected