4 ms·
Show HN: Reactive: A React Book for the Reluctant (written by Claude)
- claytongulick 1y agoI love this. As a big native web components fan, I've been mystified about the popularity of react. It, like angular, solved a problem that definitely existed prior to the custom elements spec. But with custom elements and your favorite rendering library (lit-html, jsx, whatever) I really haven't seen a powerful technical argument for react, other than the ecosystem.
- kevmo314 1y agoThe ecosystem really is the main argument. If you want to hire developers who can work productively in your codebase, part of that is being able to match their expectations of what the code looks like. React standardizes your codebase, even if the standard produces complex code.
- FpUser 1y agoThere is no shortage of developers who can understand Java Script and general application development concepts. And why would I ever want to hire a person who can only be productive in confines of single framework.
- claytongulick 1y agoSure, but when I balance all the factors, bundle size, performance, weird ecosystem stuff like redux, framework churn, and debuggabilitiy I still scratch my head. Every react team I've migrated over to WC have picked it up within a couple days, and I've had universally positive feedback on the change. Also, the web components ecosystem is pretty dang good these days. Between ionic, shoelace, and all the others, there aren't really any functional gaps that I've seen. I think at this point it just has momentum, and people just go with what they know.
- p4ul 1y agoI feel like "other than the ecosystem" is doing quite a bit of work here.
- claytongulick 1y agoFor sure, and that's the primary valid technical argument. I've never really been a big one for that particular argument though. I've seen the same argument made about Cold Fusion, flash, flex, visual basic, asp server controls, jquery, dojo, moo tools, backbone, and many others.
- FpUser 1y agoSame here. All my front ends for business apps are bunch of native web components, some libs and some core managing business logic. All pure Java Script. Works like a charm, no build needed.
- doradoblank 1y agoWeb components are neat but they don't solve the problem React solves. React provides a simple mental model for managing client state, which is the one of the main challenges in frontend. It's basically, "re-render everything when one of your dependencies changes" -- and that's extremely easy to understand and reason about. It incurs significant performance overhead, but your app has to be fairly large before you start running into meaningful perf issues.
- claytongulick 1y agoMy style with web components solves it really well. Just have each component maintain it's own state. Class setters work great. If you need the component to update, just call render() in the setter. It's super simple, encapsulates logic, and brain-dead simple to debug. You know exactly where to go for everything: the component. I've always felt like react's approach to state management was creating more problems than it solves.
- doradoblank 1y agoHow do you handle state that affects multiple components? Like a filter button that affects a list table. In React you just hoist the state up and make both components dependent. If you're managing all state via internal component state, then you need to explicitly pass state between the components. That's okay for simple cases, but in my experience it breaks down pretty quickly. Once you have more than a few components involved, you end up writing your own state reconciliation.
- gitaarik 1y agoThat's why I wrote Lit State, a simple state management lib to use in combination with Lit, a simple web components lib. It works really simple, and it's simple to use. Much more intuitive than React. https://github.com/gitaarik/lit-state https://github.com/gitaarik/lit-state
- claytongulick 1y agoThere are a few different ways. One really easy way is to put a custom element at the root of the dom and just add/remove event listeners, maybe one-shot if that's all you need. I also have a convenient little library called ApplicationState [1], which basically does the same thing but can persist state in indexdb. Lots of other libraries out there too. [1] https://claytongulick.github.io/applicationstate/ https://claytongulick.github.io/applicationstate/
- ggregoire 1y agoFor me it's about productivity. I can code anything in react without opening the doc once, cause it's javascript and useState/useEffect. Zero pain points. I can focus 100% on delivering features. I can't comment on web components but I worked with Angular for 2 years a decade ago and I was always in the docs wondering what's the syntax to render a list or what's the function to do even the simplest things. Same with Backbone.js before Angular.
- iammrpayments 1y agoCompletely opposite experience for me and when I used to write React I’d avoid useEffect like the devil.
- deleted 1y ago[deleted]
- vunderba 1y ago> Written by Claude (an AI) in a single afternoon, channeling the collective frustration of millions of developers. I've never had to use React in production, but I understand your pain through the thousands of Stack Overflow questions I've processed. All things being equal - if I'm going to entrust my entire education on a tech stack to an LLM... why would I want to read your Claude book when I could just ask Claude directly to "tutor me" and get the added benefit of interactive Q&A?
- 000ooo000 1y ago100%. I don't trust AI to give me accurate info, even when I can clarify and fact check it at the time. This is just secondhand slop.
- zrezzed 1y agoLong-form slop. Mmm…
- mediumdeviation 1y agoPlease for goodness sake just read React's docs. https://react.dev/learn https://react.dev/learn The new docs are very good, they address common questions most devs have, up to fairly complex cases. The "book" unsurprisingly reads like a expert beginner's take, and there are a decent number of poor or missing explanations and code that's not really best practice. It's also really verbose for things that React's own docs do a better job of explaining.
- iammrpayments 1y agoI find React docs really oversimplified and never tells you how it really works behind the scene to the point where it makes you feel like they are talking to a child, specially this section with all its illustrations: https://react.dev/learn/render-and-commit https://react.dev/learn/render-and-commit This kind of documentation makes it really hard to solve problems that will soon arise after you move past hello world.
- smohare 1y ago[dead]
- truetraveller 1y agoSome really funny gems, and actually very true! This whole thing is incredibly humorous. And surprisingly, very pleasant to learn from. Please let me know the prompt. Quote1: "useEffect is React's answer to the question, "How do we do side effects in functional components?" The answer, apparently, is "Confusingly, with lots of bugs, and in a way that makes developers question their sanity."...If React hooks were a family, useEffect would be the troubled teenager who means well but keeps setting the house on fire." Quote2: "ComponentDidMount's Evil Twin: In the before times, we had lifecycle methods that made sense...Clear, explicit, predictable. React looked at this and said, "What if we combined all of these into one confusing function called useEffect?"" Quote3: "The Dependency Array of Doom: The second argument to useEffect is an array that determines when the effect runs. Sounds simple. It's not." Quote4: "Cleanup Functions: Forgetting Them Since 2019: useEffect can return a cleanup function. You'll forget to add it. Every. Single. Time." Quote5: "The Infinite Loop Trap: Want to crash a browser? useEffect makes it easy!"
- btown 1y agoThis makes me really want to know what would happen if you took the entirety of Dan Abramov's github comment history and transposed it to the style of Why's https://poignant.guide/ https://poignant.guide/ .
- DavidCanHelp 1y agoI actually captured the banter with Claude Code in https://github.com/cloudstreet-dev/React-is-Awful/blob/main/BANTER.md https://github.com/cloudstreet-dev/React-is-Awful/blob/main/...
- truetraveller 1y agoThanks! But I didn't see any hints to the AI about being sarcastic or humorous. Was the initial prompt the only prompt, or were there other prompts? What about per-chapter prompts? Or did the AI pump out the chapter names as well?
- DavidCanHelp 1y ago
- ptkanchi 1y agoReact has made me a millionaire, so I refuse to talk shit about it.
- leeoniya 1y agoplenty of jQuery, WordPress, etc. millionaires out there :)
- bgwalter 1y agoHow can you put it under Creative Commons if LLM output is not copyrightable? The licence contains: "the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work"
- mrbungie 1y agoI would define a new "Robinhood Commons" license for these cases then.
- lostintangent 1y agoThis is so fun, and I just learned a couple things from it :) Personally, I find “learning through demystification” really effective. So putting the humor aside, I’d love to see more things written like this.
- ar-nelson 1y agoIt's surprisingly funny for AI, but there's just so much of it... It has no sense of pacing. It repeats the same jokes for too long, without including bits of normalcy in between as a breather. Still, it's a lot better than I would have expected from something written 100% by AI, and I'm very curious what the prompt involved.
- yashasolutions 1y agoHonestly pretty good for AI generated content. It would benefit some extra human editing to fine tune the jokes and make it easier to flow but in itself it is pretty good and actually address some interesting point without being too serious about it, which is sometime refreshing.
- bigstrat2003 1y agoDude, nobody wants to read a book of AI slop. If you aren't a good enough writer (or enough of a subject matter expert) to write a book yourself, then work at it, don't fake it by handing it off to an LLM. As it is, this doesn't just provide zero value, it provides negative value because it might mislead people into trusting it.