From b9f258f503005d4d4077ab2fb9239696e6ed923a Mon Sep 17 00:00:00 2001 From: Alex Scott Date: Thu, 28 Oct 2021 12:14:31 -0400 Subject: [PATCH] fix(RadioButtons): allow for options to be updated via change of the options prop --- src/RadioButtons/index.js | 24 +++++------------- src/RadioButtons/index.stories.js | 42 +++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 18 deletions(-) create mode 100644 src/RadioButtons/index.stories.js diff --git a/src/RadioButtons/index.js b/src/RadioButtons/index.js index 3890d4f5c..8456c8400 100644 --- a/src/RadioButtons/index.js +++ b/src/RadioButtons/index.js @@ -13,29 +13,18 @@ i.e. /> */ -const RadioButtons = (props) => { - const [radioOptions, setRadioOptions] = useState([]); - - useEffect(() => { - setRadioOptions(props.options); - }, []); - - const { initialValue, ...nativeElementProps } = props; - +const RadioButtons = ({ options, name, initialValue, ...containerProps }) => { return ( -
- {Object.entries(radioOptions).map(([label, value]) => ( +
+ {Object.entries(options).map(([label, value]) => (
-