Passing forwardedRef to Slider
Reviewed By: sahrens Differential Revision: D8345883 fbshipit-source-id: d2affdba14d38593541e591fe72006c76fca166f
This commit is contained in:
parent
160bf731e5
commit
f50ce0850d
|
@ -194,10 +194,8 @@ type Props = $ReadOnly<{|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const Slider = (
|
const Slider = (
|
||||||
props: $ReadOnly<{|
|
props: Props,
|
||||||
...Props,
|
forwardedRef?: ?React.Ref<'RCTActivityIndicatorView'>,
|
||||||
forwardedRef?: ?React.Ref<'RCTActivityIndicatorView'>,
|
|
||||||
|}>,
|
|
||||||
) => {
|
) => {
|
||||||
const style = StyleSheet.compose(
|
const style = StyleSheet.compose(
|
||||||
styles.slider,
|
styles.slider,
|
||||||
|
@ -230,6 +228,7 @@ const Slider = (
|
||||||
return (
|
return (
|
||||||
<RCTSlider
|
<RCTSlider
|
||||||
{...props}
|
{...props}
|
||||||
|
ref={forwardedRef}
|
||||||
style={style}
|
style={style}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
onSlidingComplete={onSlidingComplete}
|
onSlidingComplete={onSlidingComplete}
|
||||||
|
@ -242,9 +241,7 @@ const Slider = (
|
||||||
};
|
};
|
||||||
|
|
||||||
// $FlowFixMe - TODO T29156721 `React.forwardRef` is not defined in Flow, yet.
|
// $FlowFixMe - TODO T29156721 `React.forwardRef` is not defined in Flow, yet.
|
||||||
const SliderWithRef = React.forwardRef((props: Props, ref) => {
|
const SliderWithRef = React.forwardRef(Slider);
|
||||||
return <Slider {...props} forwardedRef={ref} />;
|
|
||||||
});
|
|
||||||
|
|
||||||
SliderWithRef.defaultProps = {
|
SliderWithRef.defaultProps = {
|
||||||
disabled: false,
|
disabled: false,
|
||||||
|
|
Loading…
Reference in New Issue