Dzień dobry,
podczas pracy z moją aplikacją wyświetla mi się poniższe ostrzeżenie:
SelectInput.js:401 MUI: You have provided an out-of-range value 309
for the select component.
Consider providing a value that matches one of the available options or ''.
The available values are "".
Gdzie zrobiłem tutaj błąd?
const [pobierz_kontrahentow,setpobierz_kontrahentow] = React.useState([]);
const [wybrany_kontrahent,setwybrany_kontrahent] = React.useState(-1);
const Baza_kontrahentow_Aktualizacja = () => {
setpobierz_kontrahentow([]);
fetch(sciezka_do_bazy+`/kontrahent_pobierz`)
.then((res) => res.json())
.then((json) => setpobierz_kontrahentow(json)) };
useEffect(
() => {
Baza_kontrahentow_Aktualizacja()
}, [props.wyswietl]);
.......
<Dialog
open={props.wyswietl}
keepMounted
aria-describedby="alert-dialog-slide-description"
sx={{
"& .MuiDialog-container": {
"& .MuiPaper-root": {
width: "100%",
maxWidth: "350px", // Set your width here
},
},
}}
>
<DialogTitle>USUWANIE KONTRAHENTA:</DialogTitle>
<DialogContent>
<FormControl sx={{ minWidth: 300 }}>
<Select
value={
wybrany_kontrahent === -1
? ""
: wybrany_kontrahent
}
onChange={(e) => {
console.log(e.target.value);
setwybrany_kontrahent(e.target.value);
}}
>
{ pobierz_kontrahentow.map((pozycja) => (
<MenuItem key={pozycja.id} value={pozycja.id}>
{pozycja.dane}
</MenuItem>
))}
</Select>
</FormControl>
</DialogContent>
<DialogActions>
<span className="styl_1">
<Button variant="contained" onClick={(e) => Przycisk_Usun()} >
USUŃ
</Button>{" "}
<Button
variant="contained"
onClick={(e) => Przycisk_Anuluj()}
>
ANULUJ
</Button>
</span>
</DialogActions>
</Dialog>