Skip to content

Commit

Permalink
fix: update value if valueProps change
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitskvmdam committed Mar 6, 2022
1 parent b0bf5e0 commit a3b87fe
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/radio-group/radio-group.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, forwardRef } from 'react'
import { useState, forwardRef, useEffect } from 'react'
import { RadioGroupContextProps } from './radio-group-context'
import { Box, BoxBaseProps } from '../box'
import { createStyledComponent, getThemeCSSObject } from '../styles'
Expand Down Expand Up @@ -44,7 +44,14 @@ export const RadioGroup = forwardRef<any, RadioGroupProps>(
}
}


const name = nameProps ?? getId()

useEffect(() => {
if(valueProps) {
setValue(valueProps)
}
}, [valueProps])

return (
<RadioGroupContext.Provider
Expand Down

0 comments on commit a3b87fe

Please sign in to comment.