I have written a code on React BoilerPlate using typescript and onChange on a select box, need to update the state of the parameter.
I have tried initialState passing data onChange function, below is the code
export const initialState = {
currencyRate: '',
currencyCode: 'USD',
};
const changeCurrency = (state = initialState, args: any) => {
produce(state, currency => {
currency.currencyCode = args.target.value;
});
console.log(currencyCode);
};
<select id="currency" name="currency" onChange={changeCurrency(
{ currencyRate: '', currencyCode: '' },
null,
)}
>
I need to set value onchange to currencyCode state
Below is the error
TS2322: Type 'void' is not assignable to type '((event: ChangeEvent) => void) | undefined'