Back when I was doing React, what pulled me in was that it WASN'T a framework for SPAs. What I got from it was the ability to build UI widgets (components, in React terms) that worked within a page, and were composable with other UI widgets. With that approach, you really wanted to keep every component self-contained. That meant a lot of bookkeeping with passing events back and forth between parent and child widgets,…
> Then introduce Redux and similar frameworks, and I totally lost interest. It's as if the entire React community forgot all the lessons they learned writing Python and C programs in college and went back to creating global state. What in the actual hell? Fair point. But could it be possible that there are lots of people doing React that never went to college and never wrote Python or C programs?
None of my projects want to be SPAs
101–110 of 362 posts
Re: None of my projects want to be SPAs
#102Earlier quoted context omitted.
Redux was the solution to server side rendering state. If you don't use redux, then keeping state synced with a server side rendered application because nearly impossible.
> Redux was the solution to server side rendering state. Could you explain what you mean by "server side rendering state"?
The client receives this initial state and uses it with the html to glue together a working UI on the client.
This removes the massive JS bloat into raw html and split JS for each component.
Instead of sending 3MB of JS, you send only the JS needed to render the current page... and send additional JS as a user navigates through your website.
Here's an example with Create React App: https://github.com/cereallarceny/cra-ssr
Re: None of my projects want to be SPAs
#103Wtf is an SPA?
If you have Javascript disabled, all you should see is a blank white screen, and if you're lucky a small note saying 'This site requires Javascript to work correctly'. That's what a SPA is
Without JS, Server Side JS defaults to good old school MVC.
Re: None of my projects want to be SPAs
#104I feel as if many sites that used to be fine and work well have regressed in usability and features and introduced unexpected behaviors and bugs since the SPA paradigm seems to have taken over. This seems especially true for many corporate, bank, shopping brand sites, etc. An example is the Capital One 360, Chase, and AMEX sites and even Reddit. Even JustWatch.com seems like it's fairly polished, still has it's quirk…
Re: None of my projects want to be SPAs
#105Back when I was doing React, what pulled me in was that it WASN'T a framework for SPAs. What I got from it was the ability to build UI widgets (components, in React terms) that worked within a page, and were composable with other UI widgets. With that approach, you really wanted to keep every component self-contained. That meant a lot of bookkeeping with passing events back and forth between parent and child widgets,…
> Then introduce Redux and similar frameworks, and I totally lost interest. It's as if the entire React community forgot all the lessons they learned writing Python and C programs in college and went back to creating global state. What in the actual hell? Fair point. But could it be possible that there are lots of people doing React that never went to college and never wrote Python or C programs?
Re: None of my projects want to be SPAs
#106Back when I was doing React, what pulled me in was that it WASN'T a framework for SPAs. What I got from it was the ability to build UI widgets (components, in React terms) that worked within a page, and were composable with other UI widgets. With that approach, you really wanted to keep every component self-contained. That meant a lot of bookkeeping with passing events back and forth between parent and child widgets,…
I'm surprised you dislike Redux simply because it's a form of global state. Sure, global variables make debugging difficult when you don't know which function changed them where and when and why. But that doesn't happen if you keep your functions pure and only make changes from within reducers – at least that's my experience. (Boilerplate, yes, Redux adds that. But at least it's all in one place, and not scattered th…
And I thank my teacher for knocking the bad habit out of me. So when I see global variables beyond the initialization of core objects, I take it as a bad code smell.
Re: None of my projects want to be SPAs
#107so, basically a "functional" front-end view-framework for client-side behavior, but with no routing.
Re: None of my projects want to be SPAs
#108I 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. So basically the same reason, except for managers to impress investors instead of developers to impress potential employers.
Not saying all SPAs are mistakes; some uses clearly are not. But most of them are.
Re: None of my projects want to be SPAs
#109Earlier quoted context omitted.
Then add a polyfill per api call to support anything but the most recent browsers, if you happen to want your site useable by people with old systems or who are at work.
...which you can selectively serve only to the old browsers :)
Re: None of my projects want to be SPAs
#110Back when I was doing React, what pulled me in was that it WASN'T a framework for SPAs. What I got from it was the ability to build UI widgets (components, in React terms) that worked within a page, and were composable with other UI widgets. With that approach, you really wanted to keep every component self-contained. That meant a lot of bookkeeping with passing events back and forth between parent and child widgets,…
I'm surprised you dislike Redux simply because it's a form of global state. Sure, global variables make debugging difficult when you don't know which function changed them where and when and why. But that doesn't happen if you keep your functions pure and only make changes from within reducers – at least that's my experience. (Boilerplate, yes, Redux adds that. But at least it's all in one place, and not scattered th…
Sticking to reducers IS a good idea and it does make things a bit better. The problem with global state goes deeper than that, though.
Often, as you learn about the structure of the data, it becomes useful to change how the data is structured and stored. In global state, you can change that in reducers, sure, but then all the places that render that data have to be updated. You don't have the option to represent the same data in different ways that might be more suitable for different parts of the application. You either have to change them all at once, or synchronize a bunch of states that really contain the same data (which is even worse).
With independent components, you do spend some time synchronizing data across components, but each component has the option of how to represent its data internally, so the effects of changing data representation in one area are usually very local, and each area of the code gets to represent the data in a way that's reasonable for what it's doing.
I'll also add that with independent components, you sometimes get components whose only real job is to manage data. That's actually sort of like a Redux! But you can spin up multiples of them without having to manage an array, and compose them or even nest them without issues.
> (Boilerplate, yes, Redux adds that. But at least it's all in one place, and not scattered throughout your app.)
To be clear, I don't really care about boilerplate. It's easy to generate that stuff, but even if you write it by hand it's faster than debugging implicit, hidden complexity. Boilerplate ISN'T the problem with Redux, as far as I'm concerned.