Why you shouldn’t use Preact and Inferno to replace React

Both preact and inferno have a package called preact-compat and inferno-compat, their authors claim these packages can replace react without requiring any code change. Don’t believe it, that’s not true. The reasons are as follows:

They failed in many unit testing

I copied 173 unit testing from react repository in GitHub, and ran them with inferno-compat and preact-compat, here is the results.

preact-compat: 87 tests failed, 86 tests passed.
inferno-compat: ProcessTerminatedError: cancel after 2 retries!

They lack of concentration

Both preact and inferno have some features that react doesn’t have, but the code about these features may not be split off preact-compat and inferno-compat.

Neither are they a superset of react, nor a subset of react, so how do they balance their own features and react features? When they can’t keep consistent with react, what can their authors do ? The anwser can be obvious.

You have a better choice

react-lite is intended as a drop-in replacement for react (with a few limitation), it can pass all unit testing mentioned above, try its best to keep consistent with react. It works very well with many libraries based on react, such as material-ui, react-bootstrap, ant-design, react-router, redux, etc.

react-lite: pass all unit testing mentioned above

react-lite is light weight, just 10+kb with gzip, and fast enough.

If your web app is written by react (follow the best practice), it can switch from react to react-lite easily without any code changing, and switch back safely (here is the usage).

Conclusion

Maybe you like preact or inferno, you want to use them and follow their own idea. That’s ok. But if you use them as a replacement of react, react-lite will be the better choice.

Other post: Five reasons about why you should try React-Lite

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.