Автозаполнение пользовательского интерфейса материала не работает в React. js - PullRequest
0 голосов
/ 14 апреля 2020

Когда я пытаюсь импортировать автозаполнение точно из документации: https://material-ui.com/components/autocomplete/ я получаю следующее сообщение об ошибке:

Failed to compile.

./node_modules/@material-ui/lab/esm/useAutocomplete/useAutocomplete.js
Attempted import error: 'unstable_useId' is not exported from '@material-ui/core/utils' (imported as 'useId').

код реакции:

/* eslint-disable no-use-before-define */
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete from '@material-ui/lab/Autocomplete';

export const MyTeamShiftPlanInput = () => {
  return (
    <Autocomplete
      id="combo-box-demo"
      options={top100Films}
      getOptionLabel={(option) => option.title}
      style={{ width: 300 }}
      renderInput={(params) => <TextField {...params} label="Combo box" variant="outlined" />}
    />
  );
}

// Top 100 films as rated by IMDb users. http://www.imdb.com/chart/top
const top100Films = [
  { title: 'The Shawshank Redemption', year: 1994 },
  { title: 'The Godfather', year: 1972 },
  { title: 'The Godfather: Part II', year: 1974 },
  { title: 'The Dark Knight', year: 2008 },
  { title: '12 Angry Men', year: 1957 },
  { title: "Schindler's List", year: 1993 },
  { title: 'Pulp Fiction', year: 1994 },
  { title: 'The Lord of the Rings: The Return of the King', year: 2003 },
  { title: 'The Good, the Bad and the Ugly', year: 1966 },
  { title: 'Fight Club', year: 1999 }
];

текущие версии MUI:

    "@material-ui/core": "^4.9.10",
    "@material-ui/lab": "^4.0.0-alpha.49",
    "@material-ui/pickers": "^3.2.10",

1 Ответ

0 голосов
/ 18 апреля 2020

На данный момент это своего рода ошибка в текущих тегах, вы можете попытаться изменить версию вашего @ material-ui / lab module

С:

"@material-ui/lab": "^4.0.0-alpha.49"

На:

"@material-ui/lab": "4.0.0-alpha.46"
...