回答編集履歴

5

https://reactjs.org/docs/integrating-with-other-libraries.html#integrating-with-dom-manipulation-plu

2018/04/03 10:59

投稿

HayatoKamono
HayatoKamono

スコア2415

test CHANGED
@@ -68,7 +68,7 @@
68
68
 
69
69
 
70
70
 
71
- # 参考
71
+ # 参考1
72
72
 
73
73
 
74
74
 
@@ -93,3 +93,23 @@
93
93
 
94
94
 
95
95
  Dan Abramovによると、この問題はjQuery側がモダンなバンドラーに上手く適合していないことが原因のようです。
96
+
97
+
98
+
99
+ # 参考2
100
+
101
+ [Integrating with DOM Manipulation Plugins
102
+
103
+ ](https://reactjs.org/docs/integrating-with-other-libraries.html#integrating-with-dom-manipulation-plugins)
104
+
105
+
106
+
107
+ jQueryをreactで使う際のガイド的な内容が載ってます。
108
+
109
+
110
+
111
+ > Note that we defined both componentDidMount and componentWillUnmount lifecycle hooks. Many jQuery plugins attach event listeners to the DOM so it’s important to detach them in componentWillUnmount. If the plugin does not provide a method for cleanup, you will probably have to provide your own, remembering to remove any event listeners the plugin registered to prevent memory leaks.
112
+
113
+
114
+
115
+ 注意書きがあると通り、componentWillMountでjQuery pluginがDOMに取り付けたイベントリスナーを外してあげないとメモリーリークの原因になるので注意して下さい。

4

a

2018/04/03 10:58

投稿

HayatoKamono
HayatoKamono

スコア2415

test CHANGED
@@ -92,4 +92,4 @@
92
92
 
93
93
 
94
94
 
95
- Dan Abramovによると、この問題はjQuery側がモダンなバンドラーに上手く適合していないことが因のようです。
95
+ Dan Abramovによると、この問題はjQuery側がモダンなバンドラーに上手く適合していないことが因のようです。

3

2018/04/03 10:50

投稿

HayatoKamono
HayatoKamono

スコア2415

test CHANGED
@@ -80,7 +80,7 @@
80
80
 
81
81
  同ページにて、ReactチームのDan Abramovが対応策を投稿しています。
82
82
 
83
- [https://github.com/facebook/create-react-app/issues/2337](https://github.com/facebook/create-react-app/issues/2337)
83
+ [https://github.com/facebook/create-react-app/issues/2337](https://github.com/facebook/create-react-app/issues/2337#issuecomment-303717356)
84
84
 
85
85
 
86
86
 

2

2018/04/03 10:49

投稿

HayatoKamono
HayatoKamono

スコア2415

test CHANGED
@@ -89,3 +89,7 @@
89
89
 
90
90
 
91
91
  > I would add that this is pretty broken (on jQuery side) as it’s not really compatible with modern bundlers, and you might have better luck using React-specific libraries instead. But it seems to work.
92
+
93
+
94
+
95
+ Dan Abramovによると、この問題はjQuery側がモダンなバンドラーに上手く適合していないことが起因のようです。

1

a

2018/04/03 10:46

投稿

HayatoKamono
HayatoKamono

スコア2415

test CHANGED
@@ -65,3 +65,27 @@
65
65
  render(<Test />, document.getElementById('root'));
66
66
 
67
67
  ```
68
+
69
+
70
+
71
+ # 参考
72
+
73
+
74
+
75
+ 解決済みイシューがありました。
76
+
77
+ [Test suite failed: jQuery is not defined #2337](https://github.com/facebook/create-react-app/issues/2337)
78
+
79
+
80
+
81
+ 同ページにて、ReactチームのDan Abramovが対応策を投稿しています。
82
+
83
+ [https://github.com/facebook/create-react-app/issues/2337](https://github.com/facebook/create-react-app/issues/2337)
84
+
85
+
86
+
87
+ 回答欄に掲載したコードは上のリンク先のコードを参考にしています。
88
+
89
+
90
+
91
+ > I would add that this is pretty broken (on jQuery side) as it’s not really compatible with modern bundlers, and you might have better luck using React-specific libraries instead. But it seems to work.