One rule
Use useEffect only to synchronize your component with something outside React. Examples: browser storage, a timer, a map widget, a chat connection, or a non-React library.
If you are only calculating a value from props or state, do it during render. If you are responding to a click or form submit, do it in the event handler.
What counts external
React already handles rendering from state and props. Your app does not need an effect to keep two React values in sync. That usually creates duplicate state and bugs.