我喜欢使用
https://github.com/Paratron/hookrouter中的useRoutes()
钩子
但我的页面太多,并且有很多重复的代码,
我尝试生成一些区域,请帮助我编写genRoutes()
函数
示例代码:
const pages = [{ name: 'aaa' },{ name: 'bbb' },{ name:'ccc' }]
const routes = genRoutes(pages)
console.log(routes)
> {
> '/aaa': () => <AaaPage />,> '/bbb': () => <BbbPage />,> '/ccc': () => <CccPage />
> }