How can I pass an object in the value of on option tag in Formik?
I am trying to send a data object from a select option tag in Formik.
I get access to a player object through props that looks like this:
{
id:'123'
name:'Life'
}
My option tag looks like this:
export const GameOption = ({ game }) => {
return (
<option value={(game.id, game.name)}>
{game.name}
</option>
)
}
And my Formik schema look like this:
import * as Yup from 'yup'
// Formik initial values
const RecordGameValues = {
gamePlayed: [],
}
// Yup validation
const RecordGameSchema = Yup.object().shape({
gamePlayed: Yup.array().min(1),
})
export { RecordGameValues, RecordGameSchema }
I want to pass in both, the game.id and game.name from the game prop through the Formik form. However, when I supply both (game.id, game.name), I get an error of Warning: The `value` prop supplied to <select> must be a scalar value if `multiple` is false.