Repository: gaearon/react-hot-loader
Pull request #665 (2017-10-11 20:54:30)

 Use console.warn in warnAboutUnnacceptedClass
I think this error is related to #378, this is a non-fatal error (hot reloading is working), I prefer this to be a warning instead of an error.


Patch:
diff --git a/.eslintrc.js b/.eslintrc.js
index 95e442f..3eaa649 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -3,7 +3,7 @@ module.exports = {
   parser: 'babel-eslint',
   rules: {
     'no-underscore-dangle': ['error', { allow: ['__REACT_HOT_LOADER__'] }],
-    'no-console': ['error', { allow: ['error'] }],
+    'no-console': ['error', { allow: ['warn', 'error'] }],
     'no-plusplus': 'off',
     'no-continue': 'off',
     'import/no-extraneous-dependencies': 'off',
diff --git a/src/patch.dev.js b/src/patch.dev.js
index e3cff07..5a89d34 100644
--- a/src/patch.dev.js
+++ b/src/patch.dev.js
@@ -125,7 +125,7 @@ hooks.reset(typeof WeakMap === 'function')
 
 function warnAboutUnnacceptedClass(typeSignature) {
   if (didUpdateProxy) {
-    console.error(
+    console.warn(
       'React Hot Loader: this component is not accepted by Hot Loader. \n' +
         'Please check is it extracted as a top level class, a function or a variable. \n' +
         'Click below to reveal the source location: \n',


Test patch:
diff --git a/test/patch.dev.test.js b/test/patch.dev.test.js
index 259d2f1..6f4de19 100644
--- a/test/patch.dev.test.js
+++ b/test/patch.dev.test.js
@@ -60,7 +60,7 @@ function runAllTests(useWeakMap) {
 
       const dynamic = () => () => <div>123</div>
 
-      const spy = jest.spyOn(console, 'error').mockImplementation(() => {})
+      const spy = jest.spyOn(console, 'warn').mockImplementation(() => {})
 
       try {
         RHL.register(f1, 'f1', '/wow/test.js')
@@ -68,32 +68,32 @@ function runAllTests(useWeakMap) {
         // emulate `static` components from node_modules
         React.createElement(f1)
         React.createElement(f1)
-        expect(console.error.mock.calls.length).toBe(0)
+        expect(console.warn.mock.calls.length).toBe(0)
         React.createElement(f2)
         React.createElement(f2)
         React.createElement(f3)
         React.createElement(f3)
 
-        expect(console.error.mock.calls.length).toBe(0)
+        expect(console.warn.mock.calls.length).toBe(0)
 
         // emulate uncatched non-static component
         React.createElement(dynamic())
-        expect(console.error.mock.calls.length).toBe(0)
+        expect(console.warn.mock.calls.length).toBe(0)
         React.createElement(dynamic())
-        expect(console.error.mock.calls.length).toBe(0)
+        expect(console.warn.mock.calls.length).toBe(0)
 
         // emulate HMR
         RHL.register(f4, 'f1', '/wow/test.js')
 
         const signature = dynamic()
         React.createElement(signature)
-        expect(console.error.mock.calls.length).toBe(1)
-        expect(console.error.mock.calls[0][0]).toBe(
+        expect(console.warn.mock.calls.length).toBe(1)
+        expect(console.warn.mock.calls[0][0]).toBe(
           'React Hot Loader: this component is not accepted by Hot Loader. \n' +
           'Please check is it extracted as a top level class, a function or a variable. \n' +
           'Click below to reveal the source location: \n'
         )
-        expect(console.error.mock.calls[0][1]).toBe(signature)
+        expect(console.warn.mock.calls[0][1]).toBe(signature)
       } finally {
         spy.mockRestore()
       }