-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathApp.tsx
More file actions
55 lines (50 loc) · 1.74 KB
/
App.tsx
File metadata and controls
55 lines (50 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import * as React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { BrowserRouter, Switch, Route } from 'react-router-dom';
import { ComponentProvider } from '@micro-frontend-react/core/lib/ComponentProvider';
import { Context } from '@micro-frontend-react/core/lib/Context';
import { ReducerRegistry } from '@micro-frontend-react/redux/lib/ReducerRegistry';
import { StoreBuilder } from '@micro-frontend-react/redux/lib/StoreBuilder';
import { injectReduxContext } from '@micro-frontend-react/redux/lib/InjectReduxContext';
import { DummyHttpClient } from './DummyHttpClient';
import { hostReducer, HostState } from './SampleHostReduxStore';
import { Home } from './Home';
const httpClient = new DummyHttpClient();
const reducerRegistry = new ReducerRegistry().register('host', hostReducer);
const appName = 'DemoApp';
const storeBuilderResult = new StoreBuilder(reducerRegistry, {})
.configureLogger(__IS_DEVELOPMENT__)
.configureSaga({ httpClient, appName })
.build();
export type AppState = {
host: HostState;
};
export function App(): React.ReactElement {
return (
<BrowserRouter>
<Switch>
<Route path="/" exact component={Home} />
<Route
path="/micro-frontend"
render={() => (
<ComponentProvider
config={{
script: 'http://localhost:8000/bundles/micro-frontend-app.js',
name: 'MicroFrontendApp',
}}
/>
)}
/>
</Switch>
</BrowserRouter>
);
}
render(
<Provider store={storeBuilderResult.store}>
<Context.Provider value={injectReduxContext(storeBuilderResult)}>
<App />
</Context.Provider>
</Provider>,
document.getElementById('app')
);