TronNatthakorn / react-native-wheel-pick

Apache License 2.0
177 stars 85 forks source link

state is not updating after onValueChange in Picker Component. #52

Open ramanguptazelhus opened 4 months ago

ramanguptazelhus commented 4 months ago
  1. Please use the componentDidUpdate method for the updating the state.
  2. Why auto scroll up and scroll down onValueChange. @slauzinho @christheyounger @kaisv7n @omeryilmazel @cinnamonpon @TronNatthakorn
matheusmazeto commented 4 months ago
  1. Please use the componentDidUpdate method for the updating the state.

@ramanguptazelhus Did you fixed this issue in your codebase? If so, can you share how you did it?

spasma commented 4 months ago

add this to the picker.js file within the class:

componentDidUpdate(prevProps) {
    if (prevProps.selectedValue !== this.props.selectedValue) {
      this.setState({ selectedValue: this.props.selectedValue });
    }
  }

PR created here: https://github.com/TronNatthakorn/react-native-wheel-pick/pull/54

Hoshiiii2602 commented 2 months ago

Worked on my app

add this to the picker.js file within the class:

componentDidUpdate(prevProps) {
    if (prevProps.selectedValue !== this.props.selectedValue) {
      this.setState({ selectedValue: this.props.selectedValue });
    }
  }

PR created here: #54