Skip to content

useState callback do not execute inside onSlidingComplete using tap. #547

@gibo77

Description

@gibo77

Environment

Android has issue.
iOS it works.

  • react-native info output:
// react-native info
 "dependencies": {
    "@react-native-community/slider": "^4.4.2",
    "@react-navigation/native": "^6.1.7",
    "@react-navigation/native-stack": "^6.9.13",
    "babel": "^6.23.0",
    "base64-js": "^1.5.1",
    "buffer": "^6.0.3",
    "react": "18.2.0",
    "react-native": "0.72.4",
    "react-native-gesture-handler": "^2.12.1",
    "react-native-reanimated": "^3.5.1",
    "react-native-safe-area-context": "^4.7.2",
    "react-native-screens": "^3.25.0",
    "react-native-size-matters": "^0.4.0",
    "react-native-splash-screen": "^3.3.0",
    "react-native-udp": "^4.1.7",
    "react-native-vector-icons": "^10.0.0",
    "upgrade": "^1.1.0"
  • are you using the new architecture?

  • which version of react & react-native are you using?

Description

The val inside the onSlidingComplete is updated when using tap in Android.
But using val in useState setSliderBrightness does not change the SliderBrightness value.

Reproducible Demo

 const [SliderBrightness, setSliderBrightness] = useState(valueItem);

  <Slider
              style={styles.SliderMargin}
              step={1}
              disabled={!isEnabled} //If Glowing is activated, the Slider could not be changed.
              tapToSeek={true}
              minimumTrackTintColor="#307ecc"
              maximumTrackTintColor="#000000"
              maximumValue={100}
              minimumValue={0}
              value={SliderBrightness} //Updates on real time. Excellent.
              onSlidingComplete={val => {
                val => setSliderBrightness(val);
                console.log('OnSlidingComplete: ', SliderBrightness);
                ChangeBrightnessHappened = true;
                //setSliderBrightness(val);
                Gibo_Fetch('IGBT=' + val + '&Angga=' + ESPSerialNum);
                // navigation.setParams({valueItem: SliderBrightness});
              }}
              onValueChange={val => setSliderBrightness(val)}
            />

Metadata

Metadata

Labels

bug reportSomething isn't workingplatform: AndroidIssue related to Android platform

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions