Support for language context in MainLoginPage.jsx
- Updated MainLoginPage component to accept a `language` prop with a default value of "en". - Modified Navbar2 to receive the `language` prop for localization. - Passed the `language` context to the Outlet for nested routes, enabling language-specific rendering in child components.
This commit is contained in:
@@ -1,16 +1,20 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import Navbar2 from "../../components/Navbar2.jsx";
|
import Navbar2 from "../../components/Navbar2.jsx";
|
||||||
import { Outlet } from "react-router-dom";
|
import { Outlet, useOutletContext } from "react-router-dom";
|
||||||
import Container from "../../components/Container.jsx";
|
import Container from "../../components/Container.jsx";
|
||||||
|
|
||||||
const MainLoginPage = () => {
|
const MainLoginPage = ({ language = "en" }) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
{/* If Navbar2 is used here, pass language */}
|
||||||
|
<Navbar2 language={language} />
|
||||||
<Container>
|
<Container>
|
||||||
<Outlet />
|
{/* Pass language to Outlet context for nested routes */}
|
||||||
|
<Outlet context={{ language }} />
|
||||||
</Container>
|
</Container>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default MainLoginPage;
|
export default MainLoginPage;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user