Ask HN: To use or not to use React?
I recently hired a developer to work on a web application I wrote in my spare time over the last two years. After having a look and pointing out several of the flaws, the developer suggested we rewrite the project using React. The web app currently relies on HTML, JavaScript, and CSS for the front-end. What are the pros and cons of using one versus the other? Is React preferable in any way to HTML, JavaScript, and CSS?
20 comments
[ 2.7 ms ] story [ 62.8 ms ] threadI already know what I need the web application to do. It uses Flask, which I understand to be akin to driving a Dodge Caravan, but it gets me place to place. Updating it to Next.js or similar only feels necessary to me when the Dodge needs to be abandoned by the side of the road. For the developer, I am sure it feels like working on a useless piece of junk, but the developer is not the one that has to drive it place to place.
https://reagent-project.github.io/
api basically unchanged since 2013 btw.
The counting component example is way too complex for me. js/setTimeout? r/atom? What is this wizardly? Is there a reason why this would be preferable, ever?
- atom is a compare and swap data structure, its lets you mutate state
- in your atom you hold a hashmap, deeply nested, that contains ALL state describing your app
- your react components reference that state with: (:some-hashmap-key @state)
- every time you update that state, any components depending on it rerender
- thats it. it’s literally the best!
My general rule is newly hired team members can't rewrite systems or major components within their first few months on the team. Of course it isn't an unbreakable rule, but the goal is to make them fully understand the product and clients. A lot of times people want to rewrite things cause they don't understand the problem you are solving and by rewriting the code base they can dig into the problem more. When in reality if you force them to live with the existing codebase for a bit it can help them and you feel more comfortable with a rewrite if that becomes necessary and usually it goes better too.
I've seen devs use react for landing sites that are 3-5 pages and maybe a couple of forms etc all because they didn't know how to interact with forms through javascript. Or one I loved is a new dev saw jquery in a project we had that was still operational and doing great but he freaked out wanting to rewrite a stable cash cow of a codebase cause jquery is "bad". I doubt/hope that isn't your case here, but just make sure you feel confident in the reasoning and it isn't just cause they know react and it is the hammer they use regardless.