Live data from Hacker News

New React docs pretend SPAs don't exist anymore

wasp-lang.dev

31–40 of 225 posts

Re: New React docs pretend SPAs don't exist anymore

#31
post #9

As far as I understand you can use these frameworks to write SPAs as well. I have no idea how well supported that use case is in the end. I find the idea that you want to handle data fetching and routing in a framework to be reasonably convincing. There are advantages here, and it's easy to get into a bit of a mess if you just fetch data in each component. The part that has stopped me from looking at the frameworks u…

Basically if you do a static export from next.js and ignore routing, you get a react SPA. You can do the same in Gatsby, but it's probably a waste of time. But... With an index.html file containing a createRoot(document.getElementById('root')).render( ) call, and parcel or vite or webpack, you can produce much the same thing. Possible that next.js will give you easier access to some more interesting ways to split you…

If you roll your own with a bundler, you will also need to integrate a router. Next.js is providing a routing layer for you. If you want to stick with a static/SPA the entire time, that's fine. You don't have to use SSR unless you need it.

https://nextjs.org/docs/advanced-features/static-html-export

Re: New React docs pretend SPAs don't exist anymore

#32
This comment thread is a little funny because every single HN thread outside of this one rants super aggressively about webpages that don't show any content before JS loads, but this thread has managed to collect the opposite group together for once because React's docs have updated to stop actively recommending tools that force that problem to happen.

Re: New React docs pretend SPAs don't exist anymore

#33

I'm still waiting for preact.js + htmx.org mashup. It probably exists somewhere, maybe https://docs.astro.build/en/concepts/islands/ or something. I just want a quick way to throw some react hooks or web components into a dom element using a library that is less than 1,000 lines of code.

Why do I hear so much about htmx and so little about unpolly, which seems everything htmx promise but with additional high level primitives for the common task?

Re: New React docs pretend SPAs don't exist anymore

#34

Starting a "new react project" should be basically creating an HTML file, and adding a script tag linking to React the JS library. Why are these developers always trying to obfuscate everything with tons and tons of layers of indirection all the time? You don't need to "bundle" anything and certainly not use some server just to add Javascript to a page (unless it's a matter of CSP of course) and you should certainly…

You can actually still do this, and it is kind of a shame it's not documented on react.dev

You need to pull in react, plus Babel standalone, and then you can use tags, which means you can bootstrap react components onto your page. But you are going to be basically running a compiler in your user's web browser. That's fine if you want to run that way, but Babel has docs that explain why you probably shouldn't (https://babeljs.io/docs/babel-standalone#when-not-to-use-bab...).

All you need is these two scripts:

    
    
[Edit - also need ReactDOM, sorry:

    
]

I think it would help if more react tutorials started from here, because it shows why you need a build process.

Here, as a JSFiddle: the React 'Hello World' they don't want you to see: https://jsfiddle.net/smLa1bco/

Re: New React docs pretend SPAs don't exist anymore

#36
post #24

I don't understand the pivot back to SSR. Tearing down and standing up the entire DOM and page memory between navigations is just unnecessary work. Little things like maintaining scroll position in the page's navigation bar meaningfully improve usability and are only achievable with a SPA-based approach. This doesn't discount the challenges of building SPAs: bundle sizes, performance, etc. can be concerns if not mana…

the biggest problem with SPAs is none of the devs making them seem to remember how nice it was to open different pages of a site in different tabs. it's all horribly phone/tablet centric. middle-clicking doesn't even pop links in new tabs because they break basic browser features. you're lucky if you can even tell what's a real link and what's just going to rearrange your current page.

Find in Page is another common casualty, and frustratingly it’s not always re-implemented by the SPA.

I think a lot of the ire against SPAs and other flavors of JS heavy pages would dissipate if devs made a point of trying to not unnecessarily break browser features and when breakage is unavoidable, furnishing replacements for the broken features that are as good as or better than the originals.

Re: New React docs pretend SPAs don't exist anymore

#38

I'm still waiting for preact.js + htmx.org mashup. It probably exists somewhere, maybe https://docs.astro.build/en/concepts/islands/ or something. I just want a quick way to throw some react hooks or web components into a dom element using a library that is less than 1,000 lines of code.

Sorry but thats not a good combo.

htmx is literally html extension. it is aimed at adding interaction to static html. Preact/react are completely opposite approach to that.

Re: New React docs pretend SPAs don't exist anymore

#39

So after graphql, micro services, nosql and serverless, the SPA + "libs not framework" crowd join the "woooops!" club. Ignoring the noise is really becoming a key skill to survive as a programmer.

SPAs, microservices, nosql (Redis), and serverless are all still alive and well, they just aren’t a hammer for all problems like (some) people treated them originally. Nerds getting overexcited about new tech is an old story and it will continue to happen indefinitely as much as we like to smug post about it.

IDK about GraphQL since I’ve not used it but I’ve read lots of stuff recently about frameworks/ORMs working to better support this type of thing more directly/natively.

Re: New React docs pretend SPAs don't exist anymore

#40
post #32

This comment thread is a little funny because every single HN thread outside of this one rants super aggressively about webpages that don't show any content before JS loads, but this thread has managed to collect the opposite group together for once because React's docs have updated to stop actively recommending tools that force that problem to happen.

I noticed that too. It’s a humble reminder to us that Hacker News isn’t one entity. It’s many people with different opinions, taking turns deciding when they want to be heard.
Post reply on HN