Reactjs MUI - useState

88 Views Asked by At

I am new to ReactjS, here I try to create a multiple select

export const MuiMultiSelect = () => {
    const [countries, setCountries] = **useState<string[]>([])**;
    console.log({countries})
    const handleChange = (event) => {
        const value = event.target.value
        setCountries(typeof value === 'string' ? value.split(',') : value);
      }
    ...

Got the following error :

"Parsing error: Missing semicolon." for the highlighted line

Not sure where the missing semicolon should go. Appreciate any pointers.

I have tried using the statement from the official documentation, but still no luck

1

There are 1 best solutions below

2
iohans On

Try ending these lines with a semicolon (const and console lines).

export const MuiMultiSelect = () => {
    const [countries, setCountries] = **useState<string[]>([])**;
    console.log({countries})
    const handleChange = (event) => {
        const value = event.target.value
        setCountries(typeof value === 'string' ? value.split(',') : value);
      }