Implement a React component that will receive an array of options:
[
{ label: 'Label 1', value: 1 },
{ label: 'Label 2', value: 2 },
{ label: 'Label 3', value: 3 },
{ label: 'Label 4', value: 4 }
]
And then render a set of radio buttons with the corresponding labels and values. Changing the radio button selection should update a value in a second, containing component's state and display that value on the page.
I expect at least two components in the final exercise, RadioGroup
and Parent
. I'm most interested in how information is passed into and out of the RadioGroup
component. We are working primarily with functional components these days, but feel free to use class-based components if you are more comfortable with them.
A repo based off of create-react-app
would be ideal, but I'll also accept an online tool like CodeSandbox or Codepen.