News for hackers. Stuff that matters.
Re:The single most impor­tant factor that dif­fer­enti­ates ... by dezmou on Wednesday July 19, 2023 @04:23PM (#36792660)
React is not reactive at all, the "state" management is you calling a function "setState" to re-render the component.

And I find manual render very usefull and once you do it, you can have a global state as simple as a global object, no need to use useState anymore.

https://github.com/dezmou/useRender

Re:The single most impor­tant factor that dif­fer­enti­ates ... by boringuser2 on Wednesday July 19, 2023 @05:27PM (#36793675)
This is extremely inadvisable for numerous reasons and goes against the entire design philosophy of React.

In short, injecting a naive render function over the react virtual dom calculation is wildly inefficient.

Re:The single most impor­tant factor that dif­fer­enti­ates ... by dezmou on Wednesday July 19, 2023 @05:57PM (#36794050)
This piece of code only rerender the component as if you do a setState, in fact it does a setState under the hood, maybe the word "render" is missleading.
Re:The single most impor­tant factor that dif­fer­enti­ates ... by Capricorn2481 on Thursday July 20, 2023 @12:18AM (#36796840)
The reactive part is every component getting that prop will update versus needing to write a function in jQuery to manually update the inner HTML of those components
Re:The single most impor­tant factor that dif­fer­enti­ates ... by dezmou on Thursday July 20, 2023 @02:46AM (#36797517)
States are scoped to a component, how "every" component that get the prop update ?
Re:The single most impor­tant factor that dif­fer­enti­ates ... by Capricorn2481 on Thursday July 20, 2023 @09:31AM (#36800183)
If you pass a prop to a child component, it will update whenever you change state

If two unrelated components are consuming the same context, it will update when that context updates.

Using Zustand, there's virtually no overhead to this and it's extremely reactive

Re:The single most impor­tant factor that dif­fer­enti­ates ... by dezmou on Thursday July 20, 2023 @11:09AM (#36801637)
"If you pass a prop to a child component, it will update whenever you change state"

Well if you update a state, every children of your component is updated as well regardless of if they have a prop passed.

I know there are way to make react trully reactive like Valtio using proxy or maybe Zustand, but my point is that useState or useContext is not "reactive" at all, you must call a function to rerender the components.

Re:The single most impor­tant factor that dif­fer­enti­ates ... by Capricorn2481 on Sunday July 23, 2023 @05:46PM (#36840182)
If by "Updated" you mean they are looked at in the virtual DOM to determine if they have to update, then yes. But children aren't repainted onto the DOM just because their parent is. This still is Reactive
Re:The single most impor­tant factor that dif­fer­enti­ates ... by dezmou on Friday July 28, 2023 @07:22PM (#36914742)
By Updated I mean that more than comparing virtual DOM to real DOM. - If you have a useEffect without dependendy, it trigger it. - If you have some map, filter, sort, any lambda in your template, it will be executed again. And that is true for your component and every children recursively.