前端项目实战叁佰陆拾陆react-admin和material ui-userMemo定义不可变的值
const items = useMemo<INavItem[]>(() => {
let navItems: INavItem[] = new Array<INavItem>();
let plantModel: INavItem = {id: 1, open: false, title: '工厂建模', children: new Array<ISubItem>()};
const plantmanager: ISubItem = {path: '/plantmodel/*', label: <NoneDecorationLink style = {{color: 'white'}} to = '/'>工厂管理</NoneDecorationLink>}
plantModel.children.push(plantmanager);
const testpage: ISubItem = {path: '/testpage/*', label: <NoneDecorationLink style = {{color: 'white'}} to = '/testpage'>测试路由</NoneDecorationLink>}
plantModel.children.push(testpage);
navItems.push(plantModel);
return navItems;
}, []);
运行结果