Skip to content

Commit 249c50c

Browse files
committed
Changes for passing data across to microfrontends
1 parent ea2d657 commit 249c50c

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

src/App.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ const {
1313
} = process.env;
1414

1515

16-
const Microfrontend1 = ({ history }) => (
17-
<Microfrontend history={history} host={microfrontend1Host} name="Microfrontend1" />
16+
const Microfrontend1 = ({ history, data }) => (
17+
<Microfrontend history={history} host={microfrontend1Host} name="Microfrontend1" data={data}/>
1818
);
1919

20-
const Microfrontend2 = ({ history }) => (
21-
<Microfrontend history={history} host={microfrontend2Host} name="Microfrontend2" />
20+
const Microfrontend2 = ({ history, data }) => (
21+
<Microfrontend history={history} host={microfrontend2Host} name="Microfrontend2" data={data}/>
2222
);
2323

24-
const MicrofrontendVueMF = ({ history }) => (
25-
<MicrofrontendVue history={history} host={microfrontendVueHost} name="MicrofrontendVue" />
24+
const MicrofrontendVueMF = ({ history, data }) => (
25+
<MicrofrontendVue history={history} host={microfrontendVueHost} name="MicrofrontendVue" data={data}/>
2626
);
2727

2828
function App() {
@@ -31,9 +31,9 @@ function App() {
3131
<React.Fragment>
3232
<Header/>
3333
<h1>Goda's microfrontend page</h1>
34-
<Route exact path="/microfrontend1" component={Microfrontend1} />
35-
<Route exact path="/microfrontend2" component={Microfrontend2} />
36-
<Route exact path="/microfrontendVue" component={MicrofrontendVueMF} />
34+
<Route exact path="/microfrontend1" component={() => <Microfrontend1 data='microfrontend 1 data'/>}/>
35+
<Route exact path="/microfrontend2" component={() => <Microfrontend2 data='microfrontend 2 data'/>} />
36+
<Route exact path="/microfrontendVue" component={() => <MicrofrontendVueMF data='microfrontend vue data'/>} />
3737
<Footer/>
3838

3939
</React.Fragment>

src/Microfrontend.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class Microfrontend extends React.Component {
2828
}
2929

3030
renderMicrofrontend = () => {
31-
const { name, window, history } = this.props;
32-
window[`render${name}`](`${name}-container`, history);
31+
const { name, window, history, data } = this.props;
32+
window[`render${name}`](`${name}-container`, history, data);
3333
}
3434

3535
render() {

src/MicrofrontendVue.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@ class MicrofrontendVue extends React.Component {
1717
script.crossOrigin = '';
1818
script.src = `${host}/${manifest['app.js']}`;
1919
document.head.appendChild(script);
20-
console.log(script)
2120

2221
script = document.createElement('script');
2322
script.id = scriptId;
2423
script.crossOrigin = '';
2524
script.src = `${host}/${manifest['chunk-vendors.js']}`;
2625
script.onload = this.renderMicrofrontend;
2726
document.head.appendChild(script);
28-
console.log(script)
2927
});
3028

3129
}
@@ -37,8 +35,8 @@ class MicrofrontendVue extends React.Component {
3735

3836
renderMicrofrontend = () => {
3937

40-
const { name, window, history } = this.props;
41-
window[`render${name}`](`${name}-container`);
38+
const { name, window, history, data } = this.props;
39+
window[`render${name}`](`${name}-container`, data);
4240
}
4341

4442
render() {

0 commit comments

Comments
 (0)