-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[No QA] introducing useResponsiveLayout hook #33425
[No QA] introducing useResponsiveLayout hook #33425
Conversation
// eslint-disable-next-line react-hooks/rules-of-hooks | ||
const {params} = useRoute<RouteProp<RouteParams, 'params'>>(); | ||
return {shouldUseNarrowLayout: isSmallScreenWidth || (params?.isInRHP ?? false)}; |
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.
This still feels like a bad practice, should we instead pass the params
as a prop and use it?
What do you think @roryabraham
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.
This looks ok to me. It's a bit weird but better than the alternative of having to use useRoute
and pass a prop every time useResponsiveLayout
needs to be used. Plus if we gave isInRHP
a default value, then it would be easy to forget to pass it when it might be different than the default.
So I think this implementation looks good
// eslint-disable-next-line react-hooks/rules-of-hooks | ||
const {params} = useRoute<RouteProp<RouteParams, 'params'>>(); | ||
return {shouldUseNarrowLayout: isSmallScreenWidth || (params?.isInRHP ?? false)}; |
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.
This looks ok to me. It's a bit weird but better than the alternative of having to use useRoute
and pass a prop every time useResponsiveLayout
needs to be used. Plus if we gave isInRHP
a default value, then it would be easy to forget to pass it when it might be different than the default.
So I think this implementation looks good
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.
Just minor suggestions.
return { | ||
shouldUseNarrowLayout: isSmallScreenWidth, | ||
}; |
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.
NAB
return { | |
shouldUseNarrowLayout: isSmallScreenWidth, | |
}; | |
return {shouldUseNarrowLayout: isSmallScreenWidth}; |
const {params} = useRoute<RouteProp<RouteParams, 'params'>>(); | ||
return {shouldUseNarrowLayout: isSmallScreenWidth || (params?.isInRHP ?? false)}; |
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.
const {params} = useRoute<RouteProp<RouteParams, 'params'>>(); | |
return {shouldUseNarrowLayout: isSmallScreenWidth || (params?.isInRHP ?? false)}; | |
// eslint-disable-next-line react-hooks/rules-of-hooks | |
const {params} = useRoute<RouteProp<RouteParams, 'params'>>(); | |
const isInRHP = params?.isInRHP ?? false; | |
const shouldUseNarrowLayout = isSmallScreenWidth || isInRHP; | |
return {shouldUseNarrowLayout}; |
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.
Not that I disagree with your comments @getusha, but given that they are pretty minor code style concerns, and there's nothing really to test here, I am going to proceed with merging this PR to keep the ball rolling – there's a lot more PRs still to come so let's be done with this one
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
🚀 Deployed to staging by https://github.com/roryabraham in version: 1.4.21-0 🚀
|
🚀 Deployed to production by https://github.com/marcaaron in version: 1.4.21-4 🚀
|
1 similar comment
🚀 Deployed to production by https://github.com/marcaaron in version: 1.4.21-4 🚀
|
🚀 Deployed to production by https://github.com/marcaaron in version: 1.4.21-4 🚀
|
Details
Breaking down #31476 into several PRs as explained here
Fixed Issues
$ #30528
Tests
N/A
Offline tests
N/A
QA Steps
N/A
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
N/A
Android: mWeb Chrome
N/A
iOS: Native
N/A
iOS: mWeb Safari
N/A
MacOS: Chrome / Safari
N/A
MacOS: Desktop
N/A