3 ms·
Yes, you would need a build step. create-react-app has existed for a very long time and works quite well though advanced applications tend to outgrow it. Alter
by shepherdjerred 2y ago
Yes, you would need a build step. create-react-app has existed for a very long time and works quite well though advanced applications tend to outgrow it.
Alternatives are Webpack (stable, boring), Vite (starting to overtake Webpack since it's significantly simpler), and 1000 other libraries.
Again, there is some movement here, but Webpack has been in a dominant position for nearly a decade and there's no reason you can't continue to use it today if you value stability. It's the equivalent of choosing to host your backend on a VPS instead of trying out serverless.
Needing a build step is part of the complexity of frontend. I think frontend is getting much simpler with build tools like Vite and the addition of ES modules. But, even with these new things coming out, you can stick to your boring stable choices on the frontend just like you can on the backend.
- WD-42 2y agoYea I'm not really buying it. create-react-app is deprecated. https://react.dev/learn/start-a-new-react-project https://react.dev/learn/start-a-new-react-project points you directly at Next.js as a *starting point* and the section about using React without a framework does it's best to discourage you from doing it. This is insane for beginners.
- nsonha 2y agoYou use a lot of words to respond to such a minor point. The main point is that actual "plain react" is useless. You need at least a router, some way to manage state, some way to manage style and so on. It's why nextjs is so popular, they are practically "plain react"
- __jonas 2y agoUseless is a massive exaggeration. > You need at least a router You only need a router if you want to build a SPA with different routes, not all web applications are that! Tons of practical React apps are just a single screen, or even embedded component. > some way to manage state You do not need an external library for complex state management, the React docs have some great guides on how to achieve this with plain React: https://react.dev/learn/scaling-up-with-reducer-and-context https://react.dev/learn/scaling-up-with-reducer-and-context > some way to manage style Plain CSS and the JSX style property are entirely enough for most apps. If you are using a build tool like Vite, you can also do CSS modules for scoping styles to your React components for more complex applications. I do agree that styling is not a strong point of React, but I don't think pulling in a dependency is necessary.
- nsonha 2y ago> https://react.dev/learn/scaling-up-with-reducer-and-context https://react.dev/learn/scaling-up-with-reducer-and-context I just wanna vomit reading that article (which is in official docs!!!). There is a much cleaner way of managing state with just a single `useState` per component instead of bringing over some Redux dogma for some inexplicable reason: ``` const [state, dispatch] = useState() // ... dispatch(doThis) dispatch(doThat) ```
- __jonas 2y agoWell of course component state is what you reach for first, which is why it is the first four sections of those docs about state management I linked: https://react.dev/learn/managing-state https://react.dev/learn/managing-state I was linking this later section about extracting state logic into a reducer, because you suggested that you would need "something for state management", I assumed you were talking about something like redux. But of course you can get pretty far with a single useState and prop drilling as well. Not sure how it supports your point that 'plain react is useless', it sounds like you are arguing against yourself with that comment?
- nsonha 2y agoNo it's a different point, in this, I just wanna express how ridiculous the official React docs can be sometimes. The Redux "pattern" you speak of, does nothing to manage state better than useState(). So I'm not sure why that API even exists, or why you think that is a good response to "need something to manage states". Let's go back to that, managing state would be for example error and pending state for every async action. In react, that basic, repetitive task is a whole celebration if you just do plain. Try do do form with per-field back-end validation feedback and see how much boilerplate you need for that.
- __jonas 2y agoAlright sure, I guess I just don't understand what it is "you need" for state management then, but I don't want to get caught up in this too much, you've made your point. I 100% agree that React is super boilerplate heavy, a lot of things are indeed 'a whole celebration', I personally choose something like Svelte over React if I have the choice, because I don't enjoy that either. All I'm saying is that plain React is not useless! It's completely fine. I don't mind working with it, it makes a tradeoff of being more ceremony but perhaps less magic and I think the tradeoff is okay.
- agos 2y agoFYI, create-react-app is basically abandoned since two years. Maybe it still works but if there's any bug, good luck
- chrisweekly 2y agoCRA is dead. Vite has emerged as its successor.