Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
fix: move check timeline play call to a useEffect hook
Browse files Browse the repository at this point in the history
  • Loading branch information
lukerohanbailey committed Jan 12, 2022
1 parent 965235e commit 8d2a0f1
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/components/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { CheckboxProps, ToggleProps } from '@react-types/checkbox';
import { gsap } from 'gsap';
import type { ChangeEvent, ComponentPropsWithRef } from 'react';
import type { ComponentPropsWithRef } from 'react';
import { useEffect, useRef } from 'react';
import { useCheckbox } from 'react-aria';
import { useToggleState } from 'react-stately';
Expand Down Expand Up @@ -107,15 +107,13 @@ export const Checkbox = ({
});
}, []);

const onChange = (event: ChangeEvent<HTMLInputElement>) => {
const checked = event.target.checked;
setSelected(checked);
useEffect(() => {
checkedTl.current.play(0);
};
}, [isSelected]);

return (
<Label>
<Input {...inputProps} {...restProps} onChange={onChange} ref={ref} />
<Input {...inputProps} {...restProps} ref={ref} />
<IconContainer>
<CheckIcon strokeDashoffset={isSelected ? '' : '21'} />
</IconContainer>
Expand Down

0 comments on commit 8d2a0f1

Please sign in to comment.