Я пытаюсь заполнить поле выбора данными из моей базы данных, но при попытке получить это сообщение об ошибке:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of `Event`.
Вот мой код:
import Select from 'react-select';
class Event extends Component {
...
render() {
const getOptions = () => {
return axios
.get("/api/categories") // [{_id: "", name: "", user: ""... }, ...]
.then(function (res) {
//res.data.map(el => ({ label: el.name, value: el._id }))
let options = res.data.map( cat => ({ value: cat._id, label: cat.name }));
return { options };
});
};
return (
...
<Select.Async
autoload={true}
loadOptions={getOptions} />
...
Я нашел эту страницу с некоторыми примерами ее реализации, но все еще не могу избавиться от ошибки.