|
|
|
|
|
by nicoburns
1728 days ago
|
|
create-react-app is incredibly bloated. My current day job inherited a CRA app, and I've spent silly amount of time getting rid of the rubbish in there. But you don't need most of it. For a simple production-ready React setup try the following libraries: - react (obviously) - redux, and react-redux (which ties react and redux together), and redux-thunk (enables asynchronous redux actions). - react-router and react-router-dom (adapts react-router for web rather than react-native) That's 6 libraries, but it's really only 3 as the auxiliary ones under redux and react-router are tiny. If you need to support older browsers then you might also need core-js to polyfill the newer apis, but that's it. And if you use esbuild to build then you won't need need all the complexity that webpack brings. |
|
We've updated the Redux core docs tutorials to teach RTK as the default [1] [2], and have examples of migrating existing Redux logic to use RTK [3].
As for the CRA aspect: I still don't really understand why some people refer to CRA as "bloated". It has all the standard pieces that have been used in the React ecosystem for years: Webpack for bundling, Babel for transpilation, Jest for testing, and ESLint for linting, and all with a very reasonable default configuration that has had thousands of hours of effort to deal with edge cases.
I'm not saying that CRA is _perfect_. The maintenance has been spotty lately, it's taken a very long time for the Webpack 5 branch to get close to release, and I'd love to see CRA adopt tools like SWC or CRA to speed up builds. But given the problems in the ecosystem before CRA, it's done exactly what it was supposed to: provided a single command to set up a new React app with good build defaults.
[0] https://redux-toolkit.js.org
[1] https://redux.js.org/tutorials/quick-start
[2] https://redux.js.org/tutorials/essentials/part-2-app-structu...
[3] https://redux.js.org/tutorials/fundamentals/part-8-modern-re...