-
Notifications
You must be signed in to change notification settings - Fork 799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React-Hot-Loader: react-🔥-dom patch is not detected. React 16.6+ features may not work. #1227
Comments
you need to add the matched version for react-hot-dom in your package file
and in your webpack config, you need to add
|
Okay, that indeed resolves the issue. But shouldn't that be added as a step 4? The readme is confusing about this. It says a Webpack plugin is required, then recommends using the Babel plugin instead. The Webpack plugin apparently patches React DOM for you to basically turn it into |
Using the Webpack plugin in conjunction with the Babel plugin does not remove the warning. Solely using the Webpack plugin doesn't either. Only the Babel plugin combined with |
For me, just using the webpack plugin (with I'm also really confused by the readme. I'm slightly worried that I might have things set up incorrectly and only working by coincidence and that it might break on an update. |
I probably forgot |
Usually, it's not about PS: Feel free to change README to be more clear and understandable. |
The Webpack plugin with @theKashey is it okay to use the Babel and Webpack plugins at the same time? Or are they meant to be used separately? |
That's ok, they are taught to be friends :) |
@rybon would you kindly share the config with us? |
Sure.
|
Alternative:
Notice:
|
Now the question is, which configuration is preferable? What are the downsides of the alternative configuration? That is not clear to me. Personally, I prefer the alternative configuration, because it requires less configuration. But if it does not work as properly as the Babel approach, I'd rather use that. |
Okay. I just noticed when using the Webpack approach without So, I guess the recommendation would be to always use the Babel plugin? And then decide to go with either the Webpack plugin or the |
You have to use |
How would you set this up using Parcel? |
Hello, "React-Hot-Loader: react-🔥-dom patch is not detected. React 16.6+ features may not work" when using https://parceljs.org/ bundler. Can this message be fixed for https://parceljs.org/ ? This is how I tried to load App (using Hooks): import { hot } from 'react-hot-loader' is there any working example using Parcel + React Hooks ? Best Regards, |
For
|
Hello @theKashey , how I start the web app: package.json snippet: |
Hi, I suffer from the same warning as other. I do not use webpack, I work on a electron app which utilizes the electron-compile. If I use yarn (yarn add react-dom@npm:@hot-loader/react-dom) I do net get the warning, but it adds
to my package.json which is something npm is not compatible with.
I would like to stick with npm instead of yarn, but I am not able to get rid of the warning with my setup: "dependencies": {
"@hot-loader/react-dom": "^16.8.6",
"electron-compile": "^6.4.4",
"electron-devtools-installer": "^2.1.0",
"electron-squirrel-startup": "^1.0.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-hot-loader": "^v4.8.4"
},
"devDependencies": {
"babel-plugin-transform-async-to-generator": "^6.24.1",
"babel-plugin-transform-es2015-classes": "^6.24.1",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"electron-forge": "^5.2.4",
"electron-prebuilt-compile": "4.0.0",
"eslint": "^3",
"eslint-config-airbnb": "^15",
"eslint-plugin-import": "^2",
"eslint-plugin-jsx-a11y": "^5",
"eslint-plugin-react": "^7"
},
"alias": {
"react-dom": "@hot-loader/react-dom"
} It says, that .compilerc (the electron-compile config) also accepts environments with the same syntax as .babelrc. My .compilerc looks like: {
"env": {
"development": {
"application/javascript": {
"presets": [
["env", { "targets": { "electron": "1.6.0" } }],
"react"
],
"plugins": ["transform-async-to-generator", "transform-es2015-classes", "react-hot-loader/babel"],
"sourceMaps": "inline"
}
},
"production": {
"application/javascript": {
"presets": [
["env", { "targets": { "electron": "1.6.0" } }],
"react"
],
"plugins": ["transform-async-to-generator", "transform-es2015-classes"],
"sourceMaps": "none"
}
}
}
} I tried to add the I also tried to use babel-plugin-module-resolver and changed the development section of my .compilerc to:
Still no luck 😢 Is there a way to get react-hot-reload to work without needing to use yarn ? |
You can always “ln” real directories. |
Thank you, I tried this already and it works. But this approach makes a local development setup quite difficult. 🤕 The issue with react-🔥-dom not being used properly is caused by babel-plugin-module-resolver and the fact babel is ignoring node_modules by default. The electron-compile project is marked as deprecated by now, so there won't be probably any support for setting aliases for npm modules in the future. I tried a different approach with setting an environment variable in the script for the local development and using the right ReactDOM respectively: import 'react-hot-loader';
import React from 'react';
import ReactDOM from 'react-dom';
import PatchedReactDOM from '@hot-loader/react-dom';
import App from './components/App';
if (process.env.REACT_DOM === 'patched') {
PatchedReactDOM.render(<App />, document.getElementById('App'));
} else {
ReactDOM.render(<App />, document.getElementById('App'));
} but although the if-else is being resolved properly, I still get the warning. |
Not, it would not work exactly this way - by default RHL would patch something names Probably the best option is to move this message from configure time to a render time(AppContainer constructor), giving you options to suppress or fix it. |
Try update RHL to the latest |
HMR breaks when using @hot-loader/react-dom I tried the fix from here: gaearon/react-hot-loader#1227 (comment) But HMR just stopped working properly - e.g chaning text i na Typgraph component would trigger a rebuild, but the web page would not update with the new text.
Just in case you arrive here while using const neutrino = require('neutrino');
const webpack = require('webpack');
const dotenv = require('dotenv');
const env = dotenv.config().parsed;
const envKeys = Object.keys(env).reduce((prev, next) => {
prev[`process.env.${next}`] = JSON.stringify(env[next]);
return prev;
}, {});
const config = neutrino().webpack();
const pluginConfig = {
plugins: [
...config.plugins,
new webpack.DefinePlugin(envKeys)
]
};
const aliasConfig = {
resolve: {
...config.resolve,
alias: {
...config.resolve.alias,
'react-dom': '@hot-loader/react-dom'
}
}
};
if (process.env.ENVIRONMENT !== 'production') {
module.exports = {
...config,
...pluginConfig,
...aliasConfig
};
} else {
module.exports = {
...config,
...pluginConfig
};
} Based on all previous discussion it seemed pretty straight forward to just inject the alias into neutrino's config. Hope someone finds this to be useful 🚀 |
@lili21 I guess it's a feature belongs to webpack, maybe webpack externals have higher priority than an alias. So u can revise your webpack.config.js as below: webpack.base.js externals: {
react: 'React',
'react-router-dom': 'ReactRouterDOM'
} webpack.development.js resolve: {
alias: { 'react-dom': '@hot-loader/react-dom' }
} webpack.production.js externals: {
'react-dom': 'ReactDOM'
} |
I have the same problems |
More or less expected. However, why do you need it as external in dev mode? |
Soooo like literally the docs resolved this issue for anyone still running into the console warning:
installs the hot-loader patch and links it for use without having to eject anything. so win-win :) Thanks React Team |
webpack.config.dev.js changes based on gaearon/react-hot-loader#1227
In local development, the console would report the following error: ``` 07:28:59.865 react-hot-loader.development.js:2375 React-Hot-Loader: react-🔥-dom patch is not detected. React 16.6+ features may not work. AppContainer @ react-hot-loader.development.js:2375 AppContainer @ VM2755:14 constructClassInstance @ react-dom.development.js:14204 updateClassComponent @ react-dom.development.js:18413 beginWork$1 @ react-dom.development.js:20186 beginWork$$1 @ react-dom.development.js:25756 ... ``` That leads to gaearon/react-hot-loader#1227 where it is noted over a series of comments that the configuration instrucations are rather confusing: > The readme is confusing about this. It says a Webpack plugin is required, then recommends using the Babel plugin instead. The Webpack plugin apparently patches React DOM for you to basically turn it into @hot-loader/react-dom, but it is unclear if it can be used in conjunction with the Babel plugin. > ... > Using the Webpack plugin in conjunction with the Babel plugin does not remove the warning. Solely using the Webpack plugin doesn't either. Only the Babel plugin combined with `@hot-loader/react-dom` and a Webpack config alias does. And eventually leads to the following "this config seems to work": ``` // App.jsx import { hot } from 'react-hot-loader/root' // ... export default hot(App) ``` ``` // .babelrc { "plugins": ["react-hot-loader/babel"] // ... } ``` ``` // package.json { "dependencies": { "react-hot-loader": "^4.8.3", "@hot-loader/react-dom": "^16.8.6" // ... } // ... } ``` ``` // webpack.config.js { // ... resolve: { alias: { 'react-dom': '@hot-loader/react-dom' } } } ```
In local development, the console would report the following error: ``` 07:28:59.865 react-hot-loader.development.js:2375 React-Hot-Loader: react-🔥-dom patch is not detected. React 16.6+ features may not work. AppContainer @ react-hot-loader.development.js:2375 AppContainer @ VM2755:14 constructClassInstance @ react-dom.development.js:14204 updateClassComponent @ react-dom.development.js:18413 beginWork$1 @ react-dom.development.js:20186 beginWork$$1 @ react-dom.development.js:25756 ... ``` That leads to gaearon/react-hot-loader#1227 where it is noted over a series of comments that the configuration instrucations are rather confusing: > The readme is confusing about this. It says a Webpack plugin is required, then recommends using the Babel plugin instead. The Webpack plugin apparently patches React DOM for you to basically turn it into @hot-loader/react-dom, but it is unclear if it can be used in conjunction with the Babel plugin. > ... > Using the Webpack plugin in conjunction with the Babel plugin does not remove the warning. Solely using the Webpack plugin doesn't either. Only the Babel plugin combined with `@hot-loader/react-dom` and a Webpack config alias does. And eventually leads to the following "this config seems to work": ``` // App.jsx import { hot } from 'react-hot-loader/root' // ... export default hot(App) ``` ``` // .babelrc { "plugins": ["react-hot-loader/babel"] // ... } ``` ``` // package.json { "dependencies": { "react-hot-loader": "^4.8.3", "@hot-loader/react-dom": "^16.8.6" // ... } // ... } ``` ``` // webpack.config.js { // ... resolve: { alias: { 'react-dom': '@hot-loader/react-dom' } } } ```
I have got the same issue and tried to resolve it according to these guide here, but got same error message. |
It Worked For Expo Web App. const createExpoWebpackConfigAsync = require('@expo/webpack-config');
module.exports = async function (env, argv) {
const config = await createExpoWebpackConfigAsync(env, argv);
// Customize the config before returning it.
config.resolve.alias['react-dom'] = '@hot-loader/react-dom';
return config;
}; |
What is the actionable thing to do here? I've followed the required steps to set it up, but still see this warning.
The text was updated successfully, but these errors were encountered: