Skip to content

Commit

Permalink
refactor: 외부 의존성 없는 함수 useCallback 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
Creative-Lee committed Jun 9, 2023
1 parent 70ac1ce commit 15d40a7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/@common/Accordion/AccordionProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PropsWithChildren, useState } from 'react';
import { PropsWithChildren, useCallback, useState } from 'react';
import AccordionContext from './context';

type AccordionProviderProps = {
Expand All @@ -8,9 +8,9 @@ type AccordionProviderProps = {
const AccordionProvider = ({ children, defaultOpen = true }: PropsWithChildren<AccordionProviderProps>) => {
const [isAccordionOpen, setIsAccordionOpen] = useState(defaultOpen);

const toggleAccordion = () => {
const toggleAccordion = useCallback(() => {
setIsAccordionOpen((prev) => !prev);
};
}, []);

return <AccordionContext.Provider value={{ isAccordionOpen, toggleAccordion }}>{children}</AccordionContext.Provider>;
};
Expand Down

0 comments on commit 15d40a7

Please sign in to comment.