-
-
Notifications
You must be signed in to change notification settings - Fork 149
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
[Tutorial Suggestion] Code Splitting #717
Comments
I have a few experience with code splitting, can you give me an example of documentation like this? |
Sure will do that sometime this week. |
In fact, I think that the best things to do would be to reference the A minimal example of code-splitting would be:
import theme from "./styles/theme";
import routes from "./constants/routes";
--- other imports ---
export default () => {
const muiTheme = React.useMemo(() => responsiveFontSizes(theme()), []);
return (
<MuiThemeProvider theme={muiTheme}>
<CssBaseline />
<Router>
<Root themeProviderOmitted scheme={scheme}>
{({ state: { sidebar } }) => (
<>
<Header />
<Sidebar />
<Content>
<React.Suspense fallback={<Loader />}>
<Routes>
{routes.map((route) => (
<Route
key={uid(route)}
element={<route.element />}
path={route.path}
/>
))}
</Routes>
</React.Suspense>
)}
</Content>
<Footer />
</>
)}
</Root>
</Router>
</MuiThemeProvider>
);
};
import React from "react";
export default [
{
element: React.lazy(() => import("../pages/Landing")),
path: "/",
},
{
element: React.lazy(() => import("../pages/Foo")),
path: "/foo",
},
{
element: React.lazy(() => import("../pages/Bar")),
path: "/bar",
},
{
element: React.lazy(() => import("../pages/NotFound")),
label: "404 Not Found",
path: "*",
},
]; |
For developers who are starting to experiment with
React
andmui-treasury
, writing a tutorial showing how to code split based on the<Content>
of thelayout library
could be a good idea.The text was updated successfully, but these errors were encountered: