Uchit Kumar Uchit Kumar - 3 years ago 93
React JSX Question

preact compat causing component to mount infinitely

I have working reactjs app with redux and react router.
I want to switch to preact.
When I updated webpack config to alias react and react dom.
Component started mounting infinitely. It mount then unmount .. goes on doing so.
Webpack config.

alias: {
"react": path.resolve(__dirname, 'react.js'),
"react-dom": path.resolve(__dirname, 'react.js')
},


react.js

var preact = require('preact-compat');
var react = {};
Object.keys(preact).forEach(function(key) {
react[key] = preact[key];
});

module.exports = react;


This file is because I am using react hot loader.
React app is working fine .. but adding preact has bug. pls guide me.

Answer Source

From my experience, preact-compat and React Hot Loader (RHL) don't work together very well (it's still on the TODO list of the developer of preact-compact, see this comment).

I work around these issues myself by not combining the two, i.e. use the "real" React and ReactDOM when I want to use RHL, or use preact-compat when I don't need RHL.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download