diff --git a/src/Button.tsx b/src/Button.tsx index 74f4a80..3422cfd 100644 --- a/src/Button.tsx +++ b/src/Button.tsx @@ -158,19 +158,23 @@ const AwesomeButton = ({ const pressAnimation = useRef(null); const [activity, setActivity] = useState(false); const [stateWidth, setStateWidth] = useState(null); - const debouncedPress = useRef( - debouncedPressTime - ? debounce( - (animateProgressEnd: (callback?: any) => void) => - onPress(animateProgressEnd), - debouncedPressTime, - { - trailing: false, - leading: true, - } - ) - : onPress - ); + + let debouncedPress = useRef( ); + React.useEffect(() => { // update the onPress props when it has changed from parent component + + debouncedPress.current = debouncedPressTime + ? debounce( + (animateProgressEnd: (callback?: any) => void) => + onPress(animateProgressEnd), + debouncedPressTime, + { + trailing: false, + leading: true, + } + ) + : onPress + + }, [ onPress ]); const layout = { backgroundActive,