Created
August 10, 2023 07:49
-
-
Save lakinmindfire/8f25dc1400dfe0d00050243406559ad1 to your computer and use it in GitHub Desktop.
single-spa example
This file contains hidden or 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
// App1 | |
const App1 = () => <div>App 1</div>; | |
export const bootstrap = [App1]; | |
export const mount = [App1]; | |
export const unmount = [App1]; | |
// App2 | |
const App2 = () => <div>App 2</div>; | |
export const bootstrap = [App2]; | |
export const mount = [App2]; | |
export const unmount = [App2]; | |
// Shell | |
import { registerApplication, start } from 'single-spa'; | |
registerApplication({ | |
name: 'app1', | |
app: () => System.import('app1'), | |
activeWhen: ['/app1'] | |
}); | |
registerApplication({ | |
name: 'app2', | |
app: () => System.import('app2'), | |
activeWhen: ['/app2'] | |
}); | |
start(); | |
// Routing | |
<Router> <Route path="/app1" component={App1} /> <Route path="/app2" component={App2} /> </Router> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment