You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry, for all my question :(, but with hooks and pullstate another world of options has opened :)
Here another question, I am not sure about the better "architecture".
Would you prefer using useStoreState within react components or within custom hooks or does it not realy makes a difference?
I am using a lot of custom hooks that load data and store them within a store using pullstate. And the hook provides the updated data using usestate of pullstate as well. So the idea is, that I only have to reference my custom hook to have access to the "loadData" method and to the data. I think that is the basic idea of hooks, as long as they are maintaining their own state.
Now with pullstate I could easy access the data directly within the component and would not need the custom hook any more...
So the "meetings" is provided by that custom hook.
What I am now thinking about is, that as far as I know, every useState triggeres a rerender of the component that uses my customhook. So when i have hooks, that use customhooks again, couldn't that cause a big rerendering?
So in that example, when within the "useContextHook" another useState is executed, then the useContextHook is rerendered and so my "useMeetingsHook" is rerendered and every component using the useMeetingHook is rerendered, correct?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi @lostpebble
Sorry, for all my question :(, but with hooks and pullstate another world of options has opened :)
Here another question, I am not sure about the better "architecture".
Would you prefer using useStoreState within react components or within custom hooks or does it not realy makes a difference?
I am using a lot of custom hooks that load data and store them within a store using pullstate. And the hook provides the updated data using usestate of pullstate as well. So the idea is, that I only have to reference my custom hook to have access to the "loadData" method and to the data. I think that is the basic idea of hooks, as long as they are maintaining their own state.
Now with pullstate I could easy access the data directly within the component and would not need the custom hook any more...
Example with a simple hook.
So the "meetings" is provided by that custom hook.
What I am now thinking about is, that as far as I know, every useState triggeres a rerender of the component that uses my customhook. So when i have hooks, that use customhooks again, couldn't that cause a big rerendering?
So in that example, when within the "useContextHook" another useState is executed, then the useContextHook is rerendered and so my "useMeetingsHook" is rerendered and every component using the useMeetingHook is rerendered, correct?
Beta Was this translation helpful? Give feedback.
All reactions