I'm trying to pass an object to a value of an jsx tag in react
I set the value of tag option to an object
onChange i got the value in tag
<Form.Select>and set the local state with the valueI console logged the local state but it returned [object Object]
I did JSON.stringify on it this way:
console.log(JSON.strigify(obj))It returned : "[object Object]"
what am I doing wrong?
here is the state of the react component:
const [selectedOp, setSelectedOp] = useState()
here is the console.log:
console.log(selectedOp)
console.log(JSON.stringify(selectedOp))
and this is the html code:
<Form.Select onChange={e => setSelectedOp(e.target.value)} className='b' style={{ display:
'inline-block' }} size="lg" aria-label="Default select example">
<option>Click to choose message</option>
{mainNotifications.map((n, i) =>
<option key={i} name="selectMessage" value={{message:n.message,type:n.type}}>hey this is an option tag </option>
)}
</Form.Select>