profile
viewpoint

Ask questionsDouble rendering (Lifecycle hook scheduled a cascading update) after item selection

Hello!

When using Downshift with controlled selectedItem property it always triggers cascading update from componentDidUpdate() after selection has changed.

Here is a guilty excerpt

if (
  this.isControlledProp('selectedItem') &&
  this.props.selectedItemChanged(
    prevProps.selectedItem,
    this.props.selectedItem,
  )
) {
  this.internalSetState({
    type: stateChangeTypes.controlledPropUpdatedSelectedItem,
    inputValue: this.props.itemToString(this.props.selectedItem),
  })
}

There should be a way to move this piece of code away from componentDidUpdate hook to run before any rendering occurs.

downshift-js/downshift

Answer questions yuriploc

@silviuavram, see if this https://github.com/reduxjs/react-redux/issues/834 issue helps you.

useful!

Related questions

TypeScript compiler error with ref passed from getInputProps to component using a forwardRef hot 2
TypeScript: definitions missing `preventDownshiftDefault` hot 1
Errors "You returned a non-DOM element. You must specify a refKey in getRootProps" hot 1
Support RefObjects for sub-components hot 1
Apollo with debounce example - downshift hot 1
Switching between controlled and uncontrolled input hot 1
source:https://uonfu.com/
Github User Rank List