-
-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(base): module federation working
- Loading branch information
1 parent
ece7ff7
commit 66b87bf
Showing
21 changed files
with
435 additions
and
125 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { createContext, PropsWithChildren, useState } from 'react'; | ||
import { RouteObject, RouteProps } from 'react-router'; | ||
import { createHashRouter, RouterProvider as ReactRouterProvider } from 'react-router-dom'; | ||
|
||
export const RouterContext = createContext<{ | ||
routes: RouteObject[]; | ||
setRoutes: (routes: RouteObject[]) => void; | ||
}>({ | ||
routes: [], | ||
setRoutes: () => {}, | ||
}); | ||
|
||
interface RouterProviderProps extends PropsWithChildren { | ||
initialRoutes?: RouteObject[]; | ||
} | ||
|
||
export const RouterProvider = ({ initialRoutes = [] }: RouterProviderProps) => { | ||
const [routes, setRoutes] = useState(initialRoutes); | ||
|
||
if (!routes?.length) { | ||
throw new Error('No routes provided to RouterProvider'); | ||
} | ||
|
||
return ( | ||
<RouterContext.Provider value={{ routes, setRoutes }}> | ||
<ReactRouterProvider router={createHashRouter(routes)} /> | ||
</RouterContext.Provider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.