Live data from Hacker News

None of my projects want to be SPAs

whatisjasongoldstein.com

291–300 of 362 posts

Re: None of my projects want to be SPAs

#291
post #278

Earlier quoted context omitted.

> The problem that you end up with past a certain scale in a component-based app without a state management framework (third party or your own) is that you're performing business logic inside view components. I respectfully disagree here. All UI views in React can be controlled via parameters. Very few components in a React application require state management. You can add parameter functions to handle various events…

> Very few components in a React application require state management. I agree. My apps usually consist of a few stateful components for dropdowns and modals and such with the remaining being functional components. The problem is the majority of "legacy" react apps I've come across seem to have the opposite ratio (I personally think this is because most react tutorials are written for fresh out of bootcamp developers…

[deleted]

Re: None of my projects want to be SPAs

#293
post #182

Earlier quoted context omitted.

sure but there are very few websites in the world that need to publicize an api, basically only sites that need to be able to function as applications. once you have a site that needs to be an application arguing for it to be single page is not that great a leap.

If you have a mobile app, you need an API, even if you‘re site does not function as an application.

unless you use Turbolinks with IOS/Android adapters or another hybrid app alternative

Re: None of my projects want to be SPAs

#294

This may be a mean thing to say, but basically I think SPA's are massively overused, because developers want to demonstrate that they can do them. Why? Because big companies like Facebook and Google use them. Why? Because they actually are doing things that require them. 99% of the SPAs in production are things that should have been done the old Rails/Django/Laravel way, but that would not set you up as a developer w…

> I have also witnessed discussions where management admits that they want something done in an SPA so that they can show that work to their investors, as a means of getting funding to do other projects. Absolutely. This extends well beyond SPAs, too, in my experience. I recently burned part of a month explaining to my senior management chain why you don't just, literally, "do machine learning." Of course, it turns o…

[deleted]

Re: None of my projects want to be SPAs

#295

Earlier quoted context omitted.

This is one page/app I built that way [0]. In this particular case it's not even fully optimized (eg js and css not minified, loads some external images...) [0] https://app.ishl.eu/

Nice site. I don't think the entire card should be clickable to collapse, though, in case you just want to select some text.

Thank you, that's a good suggestion. I have changed that.

Re: None of my projects want to be SPAs

#296

Earlier quoted context omitted.

Thinking of Redux as a 'detached state tree' that the whole app can subscribe too might give a better picture of some problems that it is solving. In React, when you lift state up and up, you mostly end up tracking lot of irrelevant state in the top most component which kind of weirdly manages lot of state just for their children. There are some genuine use cases of Redux by tracking the whole 'app state' in a detach…

> In React, when you lift state up and up, you mostly end up tracking lot of irrelevant state in the top most component which kind of weirdly manages lot of state just for their children. I'm not sure why you think the data is irrelevant, or why the component manages it "weirdly". I'll point out that these top components actually share a lot in common with Redux, except that they can be duplicated and composed with o…

> I'm not sure why you think the data is irrelevant

I believe the GP meant "unrelated". Can you drop your top level component into another application with different children and still have it work? Can you move the child components to another view tree and still have them work? It seems like what you are describing is a top level component that is tightly coupled to its descendants with too many responsibilities. In the ideal react app architecture you should be able to take any component and move it anywhere else in the app and it should Just Work. This is the problem redux is supposed to solve, and I would argue that by enforcing an explicit pattern that most experienced react developers know, you will get closer to that ideal than if you have a variety of home grown solutions that vary from project to project (and even from developer to developer on the same project). "The Tyranny of Structurelessness" etc etc.

Re: None of my projects want to be SPAs

#297

Earlier quoted context omitted.

You have information which has global nature, used in multiple sorts of the application. This could be, among other things - STDIN/STDOUT/STDERR file handles - static configuration - some parts of runtime configuration - application info (in a game maybe current score, current level, active players, ...) All that information exists only once and is needed in many parts.

>exists only once and is needed in many parts. I think many people could argue that this concept itself is a bit misguided. There are plenty of application patterns and architectures that help you move stateful data around your app and translate it for the components who need to consume it or change it, while hiding it from components in the tree which do not interact with or care about the state. If you have many di…

Sorry to reply twice to the same comment, but if you have an instance of a user model, and you need to display the model data in the navigation bar, on the user profile page, and in a comment thread, how would you manage that data? And do you think that having a single source of truth reduces complexity or creates more problems than it solves?

Re: None of my projects want to be SPAs

#298

I've found the most annoying aspect of using a SPA is having to consume your own API's. Using Swagger or gRPC on both ends helps immensely. These, combined with Angular CLI or Create React App, allow me to be just as productive as the pre-spa days

I think the beauty of SPAs is consuming your own APIs, because it makes you realize that your website is just another client application . Nobody worth their salt would recommend coupling display components and database manipulation together in an iOS or Android app. A webpage is the same thing, because it's not running on your server, it's running in the browser on the user's computer . With this blog post, like mos…

I guess another real advantage of SPA is that you get an API for free. Last place I worked, the product people had a genius idea to "build a public API". They decided to give us half a year to do it.

We had a SPA using OAuth.

I spent a few weeks adding docs, ran Swagger codegen, then declared it finished. Every call our front-ends used was now part of an API. Then we just trimmed out the parts we didn't want to officially support.

Re: None of my projects want to be SPAs

#299

Earlier quoted context omitted.

> This may be a mean thing to say, but basically I think SPA's are massively overused, because developers want to demonstrate that they can do them. Unfortunately this is another side effect of the broken hiring process in IT. Recruiters are scanning resumes for the hottest buzzwords, hiring managers want people who have experience with whatever is currently hyped, so developers naturally steer towards those technolo…

Some years ago, 3 of us picked React for a startup. I consider it the single biggest mistake in my career, but we picked it not for the reason you mention. We didn't think that far (I was perhaps a junior, but the others weren't). It was just a matter of picking the frontend framework that we liked the best (I think the options were between Backbone, Ember, AngularJS, React). In our minds we did pick the simple optio…

> I consider it the single biggest mistake in my career

I have to ask... what went so wrong? If you had a time machine, what would you tell your younger self?

Re: None of my projects want to be SPAs

#300
post #58

Earlier quoted context omitted.

Having used the internet for 25 years I can confidently say most React apps are far smaller than most jQuery apps, mainly because jQuery apps didn't use compilers or bundlers. Hell, most didn't even use minifiers . Even ignoring that, React app sizes are getting better. Modern React apps (basically since 16.7) that are written with things like Suspense, lazy, and hooks are usually pretty small. Writing functional com…

> Modern React apps (basically since 16.7) that are written with things like Suspense, lazy, and hooks are usually pretty small. Come on, 16.7 was released in December and 16.8, with stable Hooks, was last week! It's interesting that React has added these features and it bodes well for the future but you can't claim capabilities that have only existed for the a few months is what constitutes "modern." React's pace of…

These features existed in the form of 3rd party libraries like react-loadable for code splitting and recompose for hooks. I don't know any serious React devs who haven't used code splitting in the past few years, and recompose was very popular as well. We just have a canonical way of doing these things now.
Post reply on HN