im trying to implement React Select on my application, is my first time using it, and i don't know what is happening. When I put the select on the code, my web turns white. I have seen that is easy to implement on JavaScript, but whatever i try on TypeScript doesn't work, and the result is always the same, my page turns white.
Here is the custom component that i'm trying to implement based on React Select:
import React from 'react';
import Select from 'react-select';
import './VehiclePicker.scss';
interface Vehicle {
id: number,
make: string,
model: string,
year: number
}
interface ArrayObjectSelectState {
selectedVehicle: Vehicle | null;
}
let state: ArrayObjectSelectState = {
selectedVehicle: null
}
const vehicles: Vehicle[] = [
{
id: 1,
make: 'Ford',
model: 'Fiesta',
year: 2003
},
.
.
{
id: 7,
make: 'Audi',
model: 'A4',
year: 2009
}
];
export default function VehiclePicker() {
return (
<div className="vehicle-picker">
<Select
value={state.selectedVehicle}
getOptionLabel={(vehicle: Vehicle) => vehicle.model}
getOptionValue={(vehicle: Vehicle) => vehicle.model}
options={vehicles}
isClearable={true}
backspaceRemovesValue={true}
/>
</div>
);
}