code split the two pages
This commit is contained in:
parent
db9dc3390b
commit
2fc0205304
2 changed files with 9 additions and 2 deletions
|
@ -2,10 +2,12 @@ import React from "react";
|
||||||
import { ApolloProvider } from "@apollo/react-hooks";
|
import { ApolloProvider } from "@apollo/react-hooks";
|
||||||
import { CSSReset, ThemeProvider, theme } from "@chakra-ui/core";
|
import { CSSReset, ThemeProvider, theme } from "@chakra-ui/core";
|
||||||
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
|
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
|
||||||
|
import loadable from "@loadable/component";
|
||||||
|
|
||||||
import apolloClient from "./apolloClient";
|
import apolloClient from "./apolloClient";
|
||||||
import HomePage from "./HomePage";
|
|
||||||
import WardrobePage from "./WardrobePage";
|
const WardrobePage = loadable(() => import("./WardrobePage"));
|
||||||
|
const HomePage = loadable(() => import("./HomePage"));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* App is the entry point of our application. There's not a ton of exciting
|
* App is the entry point of our application. There's not a ton of exciting
|
||||||
|
|
|
@ -141,7 +141,12 @@ function SubmitPetForm() {
|
||||||
|
|
||||||
const onSubmit = (e) => {
|
const onSubmit = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
loadPet({ variables: { petName } });
|
loadPet({ variables: { petName } });
|
||||||
|
|
||||||
|
// Start preloading the WardrobePage, too!
|
||||||
|
// eslint-disable-next-line no-unused-expressions
|
||||||
|
import("./WardrobePage");
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in a new issue