From 873b639dbae11dca566ad7f9bea351f606b000dc Mon Sep 17 00:00:00 2001 From: Ava Date: Sat, 20 May 2023 19:29:27 +0900 Subject: [PATCH] feat: Synthetic press functionality depending on isChecked state update --- lib/BouncyCheckbox.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/BouncyCheckbox.tsx b/lib/BouncyCheckbox.tsx index 2da31fd5..101c07d2 100644 --- a/lib/BouncyCheckbox.tsx +++ b/lib/BouncyCheckbox.tsx @@ -72,6 +72,12 @@ class BouncyCheckbox extends React.Component { this.setState({ checked: this.props.isChecked || false }); } + componentDidUpdate(prevProps: { isChecked: boolean | undefined }) { + if (this.props.isChecked !== prevProps.isChecked) { + this.setState({ checked: this.props.isChecked || false }); + } + } + bounceEffect = (value: number, velocity: number, bounciness: number) => { const { useNativeDriver = true } = this.props; Animated.spring(this.state.bounceValue, {