Hello I'm having this error:
Argument of type 'string' is not assignable to parameter of type 'SetStateAction<number>'.
this is a part of my code:
.
.
.
const[ idPadre, setIdPadre ] = useState<number>(0);
.
.
.
<select
onChange={ (e) => setIdPadre( e.target.value ) }
value={ idPadre }
>
<option value="">Select...</option>
{data.map((item) => {
return <option key={item.id}
value={ item.id }
>{item.description}</option>
})}
</select>
so, I'm adding data from file json and I want that select an item and value get id.
setIdPadre( e.target.value )
the valuee.target.value
potentiolly is a string not anumber
as you set in youruseState<number>(0);
. Either ParseInt it or setuseState
tostring
not anumber
or if you want to accept both string and numbers then douseState<number | string>(0);
– Revers