I'm confused about whether I should be using a setState callback or the useEffects hook when updating state in my application. On my dashboard, I have a loggedInUser object, which has these fields
cashAssets
stockASsets
bondAssets
From my dashboard, I have components with execute transaction buttons, which work similarly,
<TransactionButton type={type} onClick={handleOnClick} />
When someone executes a transaction, that could affect all of the three above fields for a loggedInUser. From my dashboard component, I'm uncertain about whether I should set these 3 fields of my user object as three state variables and further how should they be updated -- using a setState callback or setting them up via useEffects, e.g.
useEffect(() => {
// Add logic to update all three
}, [cashAssets, stockAssets, bondAssets]);
or should I be treating the loggedInUser object as a state variable?