r/javascript • u/gyj129 • Dec 03 '16
Why you shouldn’t use Preact and Inferno to replace React
https://medium.com/@guyingjie129/why-you-shouldnt-use-preact-and-inferno-to-replace-react-4000ffb44572#.dox7zk5fx8
u/trueadm Dec 05 '16
Note: I'm the author of Inferno.
After going through the tests, it's clear that to pass these tests (even if they are using public API) you have to bake in the slow internals from React. For example, with non-keyed children, React assigns each child a key based off its index. There are several other things too.
I spent about 4 hours doing all these changes to make Inferno pass about 70% of the React tests only to find out that these "small" changes add up. I'd essentially built a replica of React's internals just to satisfy tests. The end result: bundle size doubled, performance dropped by about 60% and time-to-parse tripled.
Out of kicks, I removed tests that require internal API knowledge (like the keys example) and all but 11 tests failed. I'll fix those cases now and push them in the next inferno-compat release.
11
u/lhorie Dec 03 '16
TL;DR: "You should use my library instead, because it passes the tests I cherrypicked. It's a subset of React that stubs out a bunch of stuff, so it's not a true drop-in replacement for React, and it's bigger and slower than the other two, but it's still a better choice because I said so."