[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.
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.
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.
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
| return { | ||
| shouldUseNarrowLayout: isSmallScreenWidth, | ||
| }; |
There was a problem hiding this comment.
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.
| 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}; |
roryabraham
left a comment
There was a problem hiding this comment.
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 Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel so the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.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