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 Oct 21, 2020
1 parent 0b0bdb7 commit 16bae74
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 16bae74

Please sign in to comment.