import React, { useEffect, useState } from 'react' import { LayoutRectangle, Pressable, PressableProps } from 'react-native' type PressableOpacityProps = PressableProps & { ripple?: boolean rippleColor?: string unstable_pressDelay?: number } const PressableOpacity: React.FC = props => { const [opacity, setOpacity] = useState(1) const [dimensions, setDimensions] = useState(undefined) useEffect(() => { props.disabled === true ? setOpacity(0.3) : setOpacity(1) }, [props.disabled]) props = { ...props, unstable_pressDelay: props.unstable_pressDelay === undefined ? 60 : props.unstable_pressDelay, } return ( setDimensions(event.nativeEvent.layout)} onPressIn={() => { if (!props.disabled) { setOpacity(0.4) } }} onPressOut={() => { if (!props.disabled) { setOpacity(1) } }}> {props.children} ) } export default React.memo(PressableOpacity)