【发布时间】:2019-09-23 17:23:12
【问题描述】:
我需要设置从远程数据中查找材料表列。 我试过了,还是不行:
const [authors, setAuthors] = useState([]);
const [state, setState] = React.useState({
columns: [
{field: 'id', title: 'ID', editable: 'never'},
{field: 'title', title: 'Titolo'},
{
field: 'author_id',
title: 'Autore',
// lookup: {12: 'cesare pavese', 124: 'david mccomb', 3: 'stephen king'},
lookup: {authors},
}
]
});
useEffect(() => {
async function getAuthors() {
const result = await axios.get(AUTHORS_ALL);
setAuthors(result.data);
}
getAuthors();
}, []);
远程调用有效,但不设置查找。 不知道有没有可能?
【问题讨论】:
-
你能告诉我们你的数据吗?不仅仅是查找,还有你传递给数据道具的内容?或者你渲染的代码?因为您的 useEffect 是正确的,但可能是您将数据传递到材料表的方式。
标签: reactjs use-effect material-table