function SidebarItem({ depthStep = 10, depth = 0, expanded, item, ...rest }) {
fetch(`http://localhost:8989/api/menu`, requestOptions)
.then(handleResponse)
.then(menu => {
let Testing;
let id;
localStorage.setItem('menu', JSON.stringify(menu));
});
const [collapsed, setCollapsed] = React.useState(true);
const { menuName, items, Icon, path, onClick: onClickProp } = item;
function toggleCollapse() {
setCollapsed(prevValue => !prevValue);
}
在这里,它总是弹出错误
function onClick(e) {
if (Array.isArray(items)) {
toggleCollapse();
}
if (onClickProp) {
// onClickProp(e, item);
<Redirect to={path} />
}
}
我是react的初学者,我发现eror预期会遇到赋值或函数调用,而当我使用函数onClick时看到了一个表达式。我用它自己的路径来创建一个动态边栏。但它会不断加剧这种错误。尽管我以多种方式尝试过,例如使用navlink,但是this.history.push和redirect