Skip to content

Commit

Permalink
refactor(accordion): ♻️ remove effect for defaultActiveId
Browse files Browse the repository at this point in the history
  • Loading branch information
navin-moorthy committed Sep 16, 2020
1 parent 8b65c23 commit 41597be
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/accordion/AccordionState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function useAccordionState(

const [state, dispatch] = React.useReducer(reducer, {
items: [],
activeItems: [],
activeItems: defaultActiveId ? [defaultActiveId] : [],
buttons: [],
allowMultiple,
loop,
Expand Down Expand Up @@ -127,12 +127,6 @@ export function useAccordionState(
moveFocus(buttons[total - 1]);
}, [buttons, total]);

React.useEffect(() => {
if (defaultActiveId) {
dispatch({ type: "addActiveItem", id: defaultActiveId });
}
}, [defaultActiveId]);

return {
...idState,
...state,
Expand Down

0 comments on commit 41597be

Please sign in to comment.