// thay vì
index("routes/home/index.tsx"),
// thì chuyển sang
layout('routes/layouts/home.tsx', [index('routes/home/index.tsx')] ),
// tạo layout template tại '/routes/layouts/home.tsx'
const HomeLayout = () => {
return <>Home Layout</>;
};
export default HomeLayout;
// nếu muốn layout template render thêm component con bên trong '/routes/home/index.tsx'
// Now on the home page, you will only see the text "Home Layout". This is because we haven't added the `Outlet` component to the layout route. The `Outlet` component is used to render the child routes of the layout route.
import { Outlet } from 'react-router';
const HomeLayout = () => {
return (
<>
<section className='max-w-6xl mx-auto px-6 my-8'>
<Outlet /> // tiếp tục render component bên trong route, là /routes/home/index.tsx
</section>
</>
);
};
export default HomeLayout;