-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
115 additions
and
45 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
SKIP_PREFLIGHT_CHECK=true | ||
BROWSER=none | ||
BROWSER=true | ||
PORT=<%= port %> | ||
WDS_SOCKET_PORT=<%= port %> |
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
13 changes: 13 additions & 0 deletions
13
packages/create-qiankun/template/react18-main/src/About.js
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,13 @@ | ||
import { Link } from 'react-router-dom'; | ||
import './App.css'; | ||
|
||
function About() { | ||
return ( | ||
<div className="App"> | ||
<h2>About</h2> | ||
<Link to="/">Link to home</Link> | ||
</div> | ||
); | ||
} | ||
|
||
export default About; |
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
19 changes: 7 additions & 12 deletions
19
packages/create-qiankun/template/react18-main/src/index.js
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 |
---|---|---|
@@ -1,17 +1,12 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom/client'; | ||
import './index.css'; | ||
import App from './App'; | ||
import reportWebVitals from './reportWebVitals'; | ||
import React from "react"; | ||
import ReactDOM from "react-dom/client"; | ||
import "./index.css"; | ||
import router from "./router/index"; | ||
import { RouterProvider } from "react-router-dom"; | ||
const root = ReactDOM.createRoot(document.getElementById("root")); | ||
|
||
const root = ReactDOM.createRoot(document.getElementById('root')); | ||
root.render( | ||
<React.StrictMode> | ||
<App /> | ||
<RouterProvider router={router} /> | ||
</React.StrictMode> | ||
); | ||
|
||
// If you want to start measuring performance in your app, pass a function | ||
// to log results (for example: reportWebVitals(console.log)) | ||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals | ||
reportWebVitals(); |
47 changes: 47 additions & 0 deletions
47
packages/create-qiankun/template/react18-main/src/router/index.js.ejs
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,47 @@ | ||
import React, { Suspense } from "react"; | ||
import Home from "../App.js"; | ||
<% if (mainRoute === 'hash') { -%> | ||
import { createHashRouter } from "react-router-dom"; | ||
<% } -%> | ||
|
||
<% if (mainRoute === 'history') { -%> | ||
import { createBrowserRouter } from "react-router-dom"; | ||
<% } -%> | ||
|
||
|
||
const AsyncComponent = ({ load }) => { | ||
const Component = React.lazy(load); | ||
return ( | ||
<Suspense> | ||
<Component /> | ||
</Suspense> | ||
); | ||
}; | ||
|
||
const routes = [ | ||
{ | ||
path: "/", | ||
element: <Home />, | ||
}, | ||
{ | ||
path: "about", | ||
element: <AsyncComponent load={() => import("../About.js")} />, | ||
}, | ||
{ | ||
path: "*", | ||
element: <Home />, | ||
}, | ||
]; | ||
const opts = { | ||
basename: "/", | ||
}; | ||
|
||
<% if (mainRoute === 'hash') { -%> | ||
const router = createHashRouter(routes, opts); | ||
<% } -%> | ||
|
||
<% if (mainRoute === 'history') { -%> | ||
const router = createBrowserRouter(routes, opts); | ||
<% } -%> | ||
|
||
export default router; |
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