I have found various questions regarding this error but unable to find the right solution.
Overview
I am trying to build a seriesradioInput components to be part of a RadioGroup. I build this through a radioGroup component which will pass down various properties to the inputs which it receives. When I map through the values of the object I get the following error:
Error: Objects are not valid as a React child (found: object with keys {radioInputs}). If you meant to render a collection of children, use an array instead.
Question
How am I suppose to properly map through Object data and use values to pass into a component without them returning as objects?
import React from 'react';
import RadioInput from './radioInput';
export const RadioGroup= props => {
const courseTypes = {
type1: {
label: "Course A"
},
type2: {
label: "Course B"
}
}
const radioInputs = Object.values(courseTypes).map(data => {
return(
<RadioInput
disabled={false}
type={"radio"}
label={data.label}
/>
)
})
return(
{radioInputs}
)
}
export default RadioGroup