Skip to content

Commit

Permalink
Made AccordionItem toggleable through "isExpanded" (#722)
Browse files Browse the repository at this point in the history
  • Loading branch information
imp-dance authored and vnys committed Nov 13, 2020
1 parent aa602ed commit 0cb94fa
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libraries/core-react/src/Accordion/AccordionItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { forwardRef, useState, ReactElement } from 'react'
import React, { forwardRef, useState, useEffect, ReactElement } from 'react'
import type { AccordionProps } from './Accordion.types'

type Props = {
Expand Down Expand Up @@ -52,6 +52,10 @@ const AccordionItem = forwardRef<HTMLDivElement, Props>(function AccordionItem(
})
})

useEffect(() => {
setExpanded(isExpanded)
}, [isExpanded])

return (
<div {...props} ref={ref}>
{Children}
Expand Down

0 comments on commit 0cb94fa

Please sign in to comment.