Skip to content

Commit

Permalink
fix: avoid initial animation in (Checkbox|RadioButton).Android (#2349)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaulz committed Nov 13, 2020
1 parent 326c1a0 commit 4481d2e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/components/Checkbox/CheckboxAndroid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,19 @@ const CheckboxAndroid = ({
const { current: scaleAnim } = React.useRef<Animated.Value>(
new Animated.Value(1)
);
const isFirstRendering = React.useRef<boolean>(true);

const {
animation: { scale },
} = theme;

React.useEffect(() => {
// Do not run animation on very first rendering
if (isFirstRendering.current) {
isFirstRendering.current = false;
return;
}

const checked = status === 'checked';

Animated.sequence([
Expand Down
8 changes: 8 additions & 0 deletions src/components/RadioButton/RadioButtonAndroid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,17 @@ const RadioButtonAndroid = ({
new Animated.Value(1)
);

const isFirstRendering = React.useRef<boolean>(true);

const { scale } = theme.animation;

React.useEffect(() => {
// Do not run animation on very first rendering
if (isFirstRendering.current) {
isFirstRendering.current = false;
return;
}

if (status === 'checked') {
radioAnim.setValue(1.2);

Expand Down

0 comments on commit 4481d2e

Please sign in to comment.