forked from SymfonyCasts/symfony-ux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaziness-dynamic-import-react-dom.diff
50 lines (47 loc) · 1.63 KB
/
laziness-dynamic-import-react-dom.diff
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
diff --git a/assets/controllers/featured-product-react_controller.js b/assets/controllers/featured-product-react_controller.js
index dbe3a63..907ef06 100644
--- a/assets/controllers/featured-product-react_controller.js
+++ b/assets/controllers/featured-product-react_controller.js
@@ -1,5 +1,4 @@
import { Controller } from 'stimulus';
-import ReactDOM from 'react-dom';
import React from 'react';
import FeaturedProduct from '../components/FeaturedProduct';
@@ -9,9 +8,11 @@ export default class extends Controller {
}
connect() {
- ReactDOM.render(
- <FeaturedProduct product={this.productValue} />,
- this.element
- )
+ import('react-dom').then((ReactDOM) => {
+ ReactDOM.default.render(
+ <FeaturedProduct product={this.productValue} />,
+ this.element
+ )
+ })
}
}
diff --git a/assets/controllers/made-with-love_controller.js b/assets/controllers/made-with-love_controller.js
index dbfe374..ca8dccb 100644
--- a/assets/controllers/made-with-love_controller.js
+++ b/assets/controllers/made-with-love_controller.js
@@ -1,13 +1,14 @@
import { Controller } from 'stimulus';
-import ReactDOM from 'react-dom';
import React from 'react';
import MadeWithLove from '../components/MadeWithLove';
export default class extends Controller {
connect() {
- ReactDOM.render(
- <MadeWithLove />,
- this.element
- )
+ import('react-dom').then((ReactDOM) => {
+ ReactDOM.default.render(
+ <MadeWithLove />,
+ this.element
+ )
+ })
}
}