-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sergei / 90221 / set right tab account for derivX when choose account from account switcher #7878
Sergei / 90221 / set right tab account for derivX when choose account from account switcher #7878
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
A production App ID was automatically generated for this PR. (log)
Click here to copy & paste above information.
|
🚨 Lighthouse report for the changes in this PR:
Lighthouse ran with https://deriv-app-git-fork-sergei-deriv-sergei-90221derivx-real-9f7481.binary.sx/ |
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## master #7878 +/- ##
==========================================
+ Coverage 20.97% 20.98% +0.01%
==========================================
Files 1502 1502
Lines 35177 35182 +5
Branches 6830 6832 +2
==========================================
+ Hits 7379 7384 +5
Misses 27084 27084
Partials 714 714
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
if (window.location.hash === '#demo-all' || window.location.hash === '#demo') { | ||
setActiveIndex(1); | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
React Hook React.useEffect has an unnecessary dependency: 'window.location.hash'. Either exclude it or remove the dependency array. Outer scope values like 'window.location.hash' aren't valid dependencies because mutating them doesn't re-render the component.
The error message is very clear, I don't know why we always ignore react-hooks/exhaustive-deps
instead of fixing it.
If you want to rerender to happen you should use useLocation()
hook instead
const location = useLocation();
React.useEffect(() => {
if (location.hash === '#real') {
setActiveIndex(0);
}
if (location.hash === '#demo-all' || location.hash === '#demo') {
setActiveIndex(1);
}
}, [location.hash]);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@farzin-deriv I think you are right, but in this file there are 2 more lines 'eslint-disable-next-line react-hooks/exhaustive-deps'
so I didn't think it's a big problem :) Ok, in a future I'll try to avoid this error. Also, thanks for the advice about useLocation()
, but I've noticed there is props.location and I've used it instead.
…90221/derivx-real-demo-switch
…gei-deriv/deriv-app into sergei/90221/derivx-real-demo-switch
LGTM! |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
⏳ Generating Lighthouse report... |
… from account switcher (deriv-com#7878) * feat: add useEffect for checking window.location.hash * chore: empty * feat: change window.location to hook useLocation() * feat: change window.location to props.location * feat: delete useLocation import
Changes:
Please include a summary of the change and which issue is fixed below:
When you need to add unit test
When you need to add integration test
Test coverage checklist (for reviewer)
Type of change