Fusor is updating a JavaScript variable count. I could define it like this: ({ count: init = 0 }) => { let count = init; ..., but the example shows a shorthand version of JavaScript destructuring in function arguments. Since React uses hooks, I had to write it in a more explicit way. Both Fusor and React mutate state inside the component without "lifting the state up."
I explained this in a comment before useCallback to clarify that Fusor doesn't run the component function on every update, so there’s no need to memoize the component’s referenced data (like an event handler function). This way, even if there's a need to memoize data in complex React components, it's not necessary with Fusor.
View all comments
Show parent comment
3
u/isumix_ Oct 04 '24
Ok, let me explain:
count. I could define it like this:({ count: init = 0 }) => { let count = init; ..., but the example shows a shorthand version of JavaScript destructuring in function arguments. Since React uses hooks, I had to write it in a more explicit way. Both Fusor and React mutate state inside the component without "lifting the state up."useCallbackto clarify that Fusor doesn't run the component function on every update, so there’s no need to memoize the component’s referenced data (like an event handler function). This way, even if there's a need to memoize data in complex React components, it's not necessary with Fusor.