4 ms·
I'm also very happy with Preact. Apparently one approach is to use React in development and Preact in production. Could anyone who does this or knows more about
by mercer 10y ago
I'm also very happy with Preact. Apparently one approach is to use React in development and Preact in production. Could anyone who does this or knows more about this explain what React offers in development?
- untog 10y agoI'd be extremely dubious of this approach, as I've been burnt before by switching things between dev and prod (like using SQLite in dev, Postgres in prod). For development, one thing that immediately comes to mind is that React has PropTypes, which help to enforce types being passed from component to component. Preact doesn't have that.
- SamBam 10y agoWouldn't that be an example of the exact reason to use React in dev and Preact in production, as OP said? PropTypes are useless in production.
- untog 10y agoYeah, it was a bad example. A better one: Preact lets you specify HTML classes using "class", React requires you to use "className". So it would be easy to trip up on that dev/prod difference. EDIT: damn it, that's a bad example as well, because it would work fine if you use React for dev (which takes className) and Preact for prod (which uses either). I still think it's a bad idea, though.
- mercer 10y agoConsidering these two bad examples (and another one in a parallel thread), I still don't really understand what the downside is...
- svachalek 10y agoPropTypes for one. And a lot of other little, "you did this but probably meant to do that" type of checks like when you use class instead of className.
- tengbretson 10y agoCorrect me if I'm wrong, but the production build of React strips out PropTypes as well doesn't it?
- doytch 10y agoIt definitely strips out PropType checks. Not sure if the underlying code is still in the production builds though.
- danabramov 10y agoIt is included in 15 but won't be in 16.