2👍
✅
The updated
hook is called after the component’s DOM has been updated due to a change in the component’s data model (to cause the component to be re-rendered). Therefore you shouldn’t change the component’s state (async or not) inside this hook otherwise the state change will cause the component to re-render which will fire the updated
hook which will change the state… and so on.
The docs explain it well:
The component’s DOM will have been updated when this hook is called, so you can perform DOM-dependent operations here. However, in most cases you should avoid changing state inside the hook. To react to state changes, it’s usually better to use a computed property or watcher instead.
Source:stackexchange.com