Preact: Fast 3kb React Alternative with the Same API, Components and Virtual DOM
preactjs.com
preactjs.com
Don't try converting a large legacy-ish codebase :)
I do want to try snowpack too though.
1-2 times a year when I go to update our app's Webpack, in a matter of 3-4 days I:
1. Get up to date on all recent developments in the world of javascript, babel, esbuild, typescript, eslint, webpack, jest and all their plugins
2. Get the chance to browse through hundreds of fresh github issues while they are still open!
3. Open a few new pull requests
4. Find out about tens of of plugins that are not being developed anymore and their new replacements which are almost the same only with a new name and slightly different API!
5. Give my laptop and build server's CPU's a good go
6. Call my therapist
It's a wonderful opportunity to keep life on edge.
The release was rushed by community pressure, and now we have a half-baked upgrade strategy. I would've happily waited another 6-12 months before v5 was released to get major plugins ready first.
Mind you that's not necessarily a direct result of the tools or those using the tools. On the other hand, resources are finite. Any time used for X (e.g., wresting with Webpack) "comes out of the budget" for Y (e.g., bug fixes) or Z (e.g., a UX designer).
Clients/customers care about their users/end-customers. And users/end-customers don't give a toss about Webpack or anything else. They care about themselves. Full stop.
This is just in the nature of progress. If any product owner was fine with a simple static website which only displays some text, I'm sure there wouldn't be any noticeable bugs in it.
It seems to be 100% compatible with React. It's fast, it's small. And with preact/compat you can use any third party react component.
I'm a particular fan of https://github.com/developit/htm, which is an alternative to JSX that simply uses JS template strings and needs no preprocessor.
Why isn’t the React team putting in these enhancements?
This can be enforced with strict rules, eslint plugins and infra but they are expensive as hell.
EDIT: 'This will cause all consumers (with incorrect mapStateToProps configuration) to rerender'
https://react-redux.js.org/next/api/hooks#useselector
It is true that all of the selector functions need to run on each change, but those are supposed to be really small pure functions and their performance should be negligible, compared with everything else that normally happens in an app.
Edit: It is absolutely possible to affect performance with Redux, especially on a large app — for example if hundreds of selectors need to run for every keystroke in a textbox.
And yeah components are supposed to select only what they need in mapStateToProps and mapDispatchToProps. But I have seen a couple of instances where this is not followed and the developer chooses to use the entire state object passed to the component. This was fixed quickly and all developers got a short doc on the do's and dont's of Redux. This is what I mean by the extra work around redux library and not the concept itself.
Also its a fairly common to see developers pushing multiple micro updates like keystrokes to redux making it slow down. This gets filtered in the reviews but it misses out sometimes. I'm guessing this to happen in many other projects too unless I'm missing out on some major update on the tooling around redux.
These problems are not because of the approach but in the implementations. I hope you get what I mean by cost in my opinion above.
Anyway we are using it at prod and allowed us to reduce our bundle sizes ;)
Preact is great but be prepared for anomalies like mine.