News for hackers. Stuff that matters.
Re:Svelte 5 Released by esperent on Saturday October 19, 2024 @09:09PM (#41892093)
I'm building a React app from scratch and since I have control this time, I'm following a strict pattern: all data manipulation (∆) happens outside of React components, and the components themselves are as lightweight as possible.

I feel like this change suddenly makes everything about the React paradigm make sense - it can be just a view layer, and when used that way, it works great.

But I can't say I've ever worked on a React app that followed this this pattern before. Perhaps this is React's fault, or perhaps it would be the same with every framework once an app gets big enough (in my limited experience with Vue and Angular, those didn't seem any different from React in this regard).

(∆) By data, I mean the data that is fed into the app from the database. There's a certain amount of data generated internally by components, I write small functional functions at the top level or in the same folder as the components to handle that, but not placed inside the component itself, which is common practice but ends up creating these huge hard to parse components.*

Re:Svelte 5 Released by qudat on Saturday October 19, 2024 @09:38PM (#41892221)
I think that’s a smart approach. You might be interested in https://starfx.bower.sh which has similar design goals
Re:Svelte 5 Released by jbhoot on Sunday October 20, 2024 @03:57AM (#41893728)
> all data manipulation (∆) happens outside of React components,

I do something similar. State and its management lives outside the React components, which only consume this state via hooks. Keeping the state in chunks, and outside the tree lets me access a chunk of state only in the components that need it.

This results into minimum amount of re-rendering of components. Component code also looks cleaner and easier to read.

Re:Svelte 5 Released by datavirtue on Sunday October 20, 2024 @11:03AM (#41895783)
This many years on and we are still trying to figure out state management. Wasn't React designed for the view?
Re:Svelte 5 Released by jbhoot on Monday October 21, 2024 @07:06AM (#41902861)
The marketing has kept changing.

I have always found state management easier in React if I keep it out of React.

Re:Svelte 5 Released by FartinMowler on Sunday October 20, 2024 @11:44AM (#41896087)
Haha, reminds me of 20 years ago when someone said they are building a PHP app from scratch and this time they won't have HTML, business logic and SQL all in one .php file. We learn as we go ;)
Re:Svelte 5 Released by nsonha on Sunday October 20, 2024 @11:47AM (#41896112)
My React fomula is React + MobX, keep the hook use to minimum, single state object per component (the classic React way), do not bother with server components at this point, you should be fine.