diff --git a/src/components/WheelPicker/Item.tsx b/src/components/WheelPicker/Item.tsx index ecb128465e..3d461782e5 100644 --- a/src/components/WheelPicker/Item.tsx +++ b/src/components/WheelPicker/Item.tsx @@ -73,6 +73,7 @@ const WheelPickerItem = memo(({ return [animatedColorStyle, style, fakeLabel ? textWithLabelPaddingStyle : styles.textPadding]; }, [style, fakeLabel, animatedColorStyle, textWithLabelPaddingStyle]); + const _fakeLabelStyle = useMemo(() => StyleSheet.flatten([fakeLabelStyle, styles.hidden]), [fakeLabelStyle]); return ( - + {label} {fakeLabel && ( - + {fakeLabel} )} @@ -122,5 +112,8 @@ const styles = StyleSheet.create({ }, disableRTL: { flexDirection: 'row-reverse' + }, + hidden: { + opacity: 0 } }); diff --git a/src/components/colorPicker/index.tsx b/src/components/colorPicker/index.tsx index 785ccde138..81f59c3ee1 100644 --- a/src/components/colorPicker/index.tsx +++ b/src/components/colorPicker/index.tsx @@ -1,4 +1,4 @@ -import React, {PureComponent} from 'react'; +import React, {useCallback, useState} from 'react'; import {StyleSheet} from 'react-native'; import {asBaseComponent} from '../../commons/new'; import Assets from '../../assets'; @@ -58,77 +58,65 @@ const ACCESSIBILITY_LABELS = { * @notes: This is a screen width component * @gif: https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/ColorPicker/ColorPicker.gif?raw=true */ -class ColorPicker extends PureComponent { - static displayName = 'ColorPicker'; +const ColorPicker = (props: Props) => { + const { + accessibilityLabels = ACCESSIBILITY_LABELS, + backgroundColor = Colors.$backgroundDefault, + initialColor, + colors, + value, + testID, + onValueChange, + animatedIndex + } = props; + const [show, setShow] = useState(false); - static defaultProps = { - accessibilityLabels: ACCESSIBILITY_LABELS, - backgroundColor: Colors.$backgroundDefault - }; - - state = { - show: false - }; + const showDialog = useCallback(() => setShow(true), []); - get animatedIndex() { - const {animatedIndex, colors} = this.props; - if (animatedIndex === undefined) { - return colors.length - 1; - } - return animatedIndex; - } + const hideDialog = useCallback(() => setShow(false), []); - showDialog = () => { - this.setState({show: true}); - }; - - hideDialog = () => { - this.setState({show: false}); - }; - - render() { - const {initialColor, colors, value, testID, accessibilityLabels, backgroundColor, onValueChange} = this.props; - const {show} = this.state; - return ( - - - -