-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathApp.js
62 lines (52 loc) · 1.79 KB
/
App.js
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
56
57
58
59
60
61
62
import React from 'react';
import ReactAdapterConsumer from './ReactAdapterConsumer';
const RemoteButton = React.lazy(() => import('app2/Button'));
// const ModernComponent = React.lazy(() => import("app2/ModernComponent"));
// Hooks not suppoorted, uncomment to verify this is a pre-hooks react version being used.
// import HookComponent from './ComponentWithHook'
class App extends React.Component {
constructor(props) {
super(props);
this.state = { input: '' };
this.setValue = this.setValue.bind(this);
}
setValue(e) {
this.setState({ input: e.target.value });
}
render() {
return (
<div>
<h1>Basic Host-Remote</h1>
<h2>App 1, Uses react version not compatible with hooks</h2>
<input onChange={this.setValue} placeholder="Type something into this input" />
<div
style={{ border: '1px red solid', padding: '10px', margin: '20px 0' }}
data-e2e="REACT__DIV_BLOCK"
>
<ReactAdapterConsumer
// any other props, passed to ModernComponent
{...this.state}
importer={() => import('app2/ModernComponent')}
>
<h3>And these are children passed into it from the legacy app</h3>
</ReactAdapterConsumer>
</div>
{/*This will Fail*/}
{/*<HookComponent/>*/}
<div
style={{ border: '1px red solid', padding: '10px', margin: '20px 0' }}
data-e2e="REACT__BUTTON_BLOCK"
>
<React.Suspense fallback="Loading Button">
<RemoteButton />
</React.Suspense>
</div>
{/*This will fail without Adapter*/}
{/*<React.Suspense fallback="Loading Button">*/}
{/* <ModernComponent />*/}
{/*</React.Suspense>*/}
</div>
);
}
}
export default App;