Page MenuHomePhabricator

[Cashtab] Use recommended react hook instead of window.location
AbandonedPublicDraft

Authored by bytesofman on Feb 9 2024, 17:31.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

React has a hook useLocation which is the recommended way to get values from the global window

Currently Cashtab is using a mix of both approaches. Most of the time useLocation is used, but sometimes we use window.location

Remove remaining instances of window.location and replace with hook. Update relevant unit tests to mock route instead of mocking the global window object.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
no-window-hash
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 27040
Build 53646: Build Diffcashtab-tests
Build 53645: arc lint + arc unit

Event Timeline

handle with search in extension

location.search should be the way to do this. However this does not always return existing params in hashrouter.

to really get away from window object, should move away from hashrouter, which you want to do anyway. so, table this until you have accomplished that.

superseded, needs to be handled with hash router deprecation which might not happen