[Cashtab] Patch improper useNavigate usage
Summary:
T3463
Current implementation is from react router 6 migration.
the navigate() function returned from the useNavigate hook should not be called as part of the rendered component. In this case, we want to trigger it when the user sends or burns their whole token balance. So, call it in a useEffect block when this state change occurs.
Remove use from Etokens screen. Getting screens to render Onboarding if the user has no wallet should be done centrally from App.js in another diff (right now, Home and Receive do it, but other screens do not).
Test Plan:
npm test
Unfortunately cannot automate this integration test as would require chronik-client to change API calls in the future and respond to websocket msgs or a bridged jest-to-regtest instance (not yet set up). To test manually
- Send or burn all of a token
- Confirm you are navigated back to home screen
- Confirm no error in dev console
Reviewers: #bitcoin_abc, emack
Reviewed By: #bitcoin_abc, emack
Differential Revision: https://reviews.bitcoinabc.org/D15710