Incompatible with hot module reload?
See original GitHub issueFirst of all, thank you for this work, 😄 it really looks a lot easier to use than react-intl
which I find a little overkill for a simple app.
I have a translated view that goes like this:
import React from 'react';
import { translate } from 'react-i18next/lib';
const LoginForm = React.createClass({
render() {
const t = this.props.t;
console.log(t); // <-- we should have the translation fn here
return (
<div>
<h3>{ t('Sign in')}</h3>
{/*...*/}
</div>
);
}
});
export default translate(['login'])(LoginForm);
On first load and manual reload it works as advertised, displaying the translated message. The console.log(t)
call returns something like function fixedT(key, options) {...}
, but when I modify something on the component and thus triggering the hot reload module (Webpack), I get undefined
and an Uncaught TypeError: t is not a function
.
Is there any way to make react-i18next compatible with HMR?
Thanks!
Issue Analytics
- State:
- Created 8 years ago
- Comments:34 (15 by maintainers)
Top Results From Across the Web
process is not defined on hot reload - Stack Overflow
I have a react app made with create react app, and hot reloading kills the page entirely with the error:
Read more >Hot Module Replacement - webpack
If Hot Module Replacement has been enabled via the HotModuleReplacementPlugin , its interface will be exposed under the module.hot property as well as ......
Read more >Hot reload fails: "This is likely a stale module that must be ...
(API version -1), but it was incompatible with the current engine API version (0). This is likely a stale module that…
Read more >Troubleshooting XAML Hot Reload - Visual Studio (Windows)
Stop the debugging session, make the change, and then restart the debugging session. If you find an unsupported scenario that you'd like to...
Read more >React Hot Loader | Best of JS
Parcel supports Hot Module Reloading out of the box, just follow step 1 and 2 of ... webpack ExtractTextPlugin is not compatible with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@gnapse you mean if you change something in the translation files you want the hmr to reload your page…not sure if that is possible…as those files are not part of the bundle.
I think the initial issue was a reload based on a change in the component…not translation files.
Personally we moved our translation to the service tier locize.com - so we do no manipulations of translations anymore inside the project repository.
Rather sure there is a way to trigger hmr doing some configurations to watch for the public folder too…but personally i prefer doing create-react-app init - so i might have less knowledge about webpack config…eventual this is a good question for stackoverflow?
I got it working. Finally. Via this post: https://github.com/i18next/react-i18next/issues/3, I was mentioned this post: https://github.com/ghengeveld/redux/blob/a68768ff8d6a4fbe7b8f6a06a8cf9b99a54aefb0/docs/recipes/WritingTests.md#testing-decorated-react-components
Basically, because in order to test the undecorated component and not the decorated translate component, I had to export the component using:
export class ComponentName extends Component { ... }
next to theexport default translate('common')(ComponentName)
at the bottom. Because I export the undecorated component next to the decorated component, I can import the undecorated component in my unit test usingimport { FilterRow } from '../components/filterRow';
instead ofimport FilterRow from '../components/filterRow';