mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Remove the onChange event for Slider
Summary: The onChange event for slider isn't necessary. Instead, it uses onValueChanged. ## What motivated this change? After D33933403, the SliderNativeComponent starts generating an onChange: true entry in its static ViewConfig's validAttributes map. **The Problem:** Slider inherits the onChange event from RCTViewManager. And in RCTViewManager, onChange is defined as an event that doesn't generate a ViewConfig validAttribute: 1. onChange is exported from [RCTViewManager customBubblingEventTypes](https://www.internalfb.com/code/fbsource/[210a214c9da7a847dd8840cae9f8341ed39a2ff6]/xplat/js/react-native-github/React/Views/RCTViewManager.m?lines=99%2C105%2C118) 2. Events exported from customBubblingEventTypes [don't insert into validAttributes](https://www.internalfb.com/code/fbsource/[8237815744b8cf7e38d9cf107a55c015f7b1545b]/xplat/js/react-native-github/React/Views/RCTComponentData.m?lines=393-398). To summarize: - onChange isn't used by slider - onChange generates an onChange: true entry in SVCs - onChange **doesn't** generate an onChange: true entry in NVC Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D34052662 fbshipit-source-id: 76bfd75c1ecbaa40d33e2b097b1f4458bf200ac2
This commit is contained in:
committed by
Facebook GitHub Bot
parent
95f950de2a
commit
f89ed90a1e
@@ -228,7 +228,6 @@ const Slider = (
|
||||
}
|
||||
: null;
|
||||
|
||||
const onChangeEvent = onValueChangeEvent;
|
||||
const onSlidingCompleteEvent = onSlidingComplete
|
||||
? (event: Event) => {
|
||||
onSlidingComplete(event.nativeEvent.value);
|
||||
@@ -250,7 +249,6 @@ const Slider = (
|
||||
disabled={disabled}
|
||||
maximumValue={maximumValue}
|
||||
minimumValue={minimumValue}
|
||||
onChange={onChangeEvent}
|
||||
onResponderTerminationRequest={() => false}
|
||||
onSlidingComplete={onSlidingCompleteEvent}
|
||||
onStartShouldSetResponder={() => true}
|
||||
|
||||
@@ -47,7 +47,6 @@ type NativeProps = $ReadOnly<{|
|
||||
value?: WithDefault<Double, 0>,
|
||||
|
||||
// Events
|
||||
onChange?: ?BubblingEventHandler<Event>,
|
||||
onValueChange?: ?BubblingEventHandler<Event>,
|
||||
onSlidingComplete?: ?DirectEventHandler<Event>,
|
||||
|}>;
|
||||
|
||||
@@ -6,7 +6,6 @@ exports[`<Slider /> should render as expected 1`] = `
|
||||
enabled={true}
|
||||
maximumValue={1}
|
||||
minimumValue={0}
|
||||
onChange={null}
|
||||
onResponderTerminationRequest={[Function]}
|
||||
onSlidingComplete={null}
|
||||
onStartShouldSetResponder={[Function]}
|
||||
@@ -27,7 +26,6 @@ exports[`<Slider /> should set disabled as false 1`] = `
|
||||
enabled={true}
|
||||
maximumValue={1}
|
||||
minimumValue={0}
|
||||
onChange={null}
|
||||
onResponderTerminationRequest={[Function]}
|
||||
onSlidingComplete={null}
|
||||
onStartShouldSetResponder={[Function]}
|
||||
@@ -53,7 +51,6 @@ exports[`<Slider /> should set disabled as false 2`] = `
|
||||
enabled={true}
|
||||
maximumValue={1}
|
||||
minimumValue={0}
|
||||
onChange={null}
|
||||
onResponderTerminationRequest={[Function]}
|
||||
onSlidingComplete={null}
|
||||
onStartShouldSetResponder={[Function]}
|
||||
@@ -79,7 +76,6 @@ exports[`<Slider /> should set disabled as true 1`] = `
|
||||
enabled={false}
|
||||
maximumValue={1}
|
||||
minimumValue={0}
|
||||
onChange={null}
|
||||
onResponderTerminationRequest={[Function]}
|
||||
onSlidingComplete={null}
|
||||
onStartShouldSetResponder={[Function]}
|
||||
@@ -105,7 +101,6 @@ exports[`<Slider /> should set disabled as true 2`] = `
|
||||
enabled={false}
|
||||
maximumValue={1}
|
||||
minimumValue={0}
|
||||
onChange={null}
|
||||
onResponderTerminationRequest={[Function]}
|
||||
onSlidingComplete={null}
|
||||
onStartShouldSetResponder={[Function]}
|
||||
|
||||
Reference in New Issue
Block a user