Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧐[问题 | question] 嵌套路由时 layout里获取不到children #11063

Closed
nikojxie opened this issue Nov 28, 2023 · 1 comment
Closed

Comments

@nikojxie
Copy link

nikojxie commented Nov 28, 2023

🧐 问题描述 | Problem description

嵌套路由时 layout里获取不到children,请问是什么原因

💻 示例代码 | Sample code

// config/routes.ts
export default [
  {
    path: '/',
    component: '../layout/index',
    routes: [
      {
        path: '/setting',
        component: './Setting/index',
        name: 'setting'
      },
    ],
  },
];

// src/layout/index.tsx
const Layout = (props) => {
  console.log(props); // {}
  return props.children
};
export default Layout;

此时打印 props 是空对象

@nikojxie
Copy link
Author

nikojxie commented Nov 28, 2023

哦,react rotuer更新了,要用<Outlet />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant