[TS migration] Migrate 'CustomDevMenu' component to TypeScript#29744
Conversation
|
@rushatgabhane Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Reviewer Checklist
Screenshots/VideosAndroid: mWeb ChromeiOS: mWeb SafariMacOS: Desktop |
|
@rushatgabhane can you approve this PR as well? |
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #24978 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
roryabraham
left a comment
There was a problem hiding this comment.
This seems weird / overcomplicated. Can we just do this instead?
// src/components/CustomDevMenu/index.tsx
function CustomDevMenu() {
return <></>;
}
CustomDevMenu.displayName = 'CustomDevMenu';
export default CustomDevMenu;// src/components/CustomDevMenu/index.native.tsx
import {useEffect} from 'react';
import DevMenu from 'react-native-dev-menu';
import toggleTestToolsModal from '@userActions/TestTool';
function CustomDevMenu() {
useEffect(() => {
DevMenu.addItem('Open Test Preferences', toggleTestToolsModal);
}, []);
return <></>;
}
CustomDevMenu.displayName = 'CustomDevMenu';
export default CustomDevMenu;|
Hi @roryabraham this is something that our guidelines encourage. Although it may seem redundant at first, it actually serves a purpose - if someone comes in later and changes something in one file, this ensures that the types will stay consistent across different platforms. 😄 |
|
Ok, I see – makes sense! Should we still simplify the types by making these components return ReactElements instead of null and making the type like this? import {ReactElement} from 'react';
type CustomDevMenuElement = {
(): ReactElement;
displayName: string;
};
export default CustomDevMenuElement;Also, I did find a way to implement the component without having to do any TS suppressions: import {useEffect} from 'react';
import DevMenu from 'react-native-dev-menu';
import toggleTestToolsModal from '@userActions/TestTool';
import CustomDevMenuElement from './types';
const CustomDevMenu: CustomDevMenuElement = Object.assign(
() => {
useEffect(() => {
DevMenu.addItem('Open Test Preferences', toggleTestToolsModal);
}, []);
return <></>;
},
{
displayName: 'CustomDevMenu',
},
);
export default CustomDevMenu; |
|
Done! @roryabraham |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
+1 |
|
+1 |
|
+1 Fixed it here #32160 |
…ts-migration/custom-dev-menu-component"" This reverts commit 23bfbf9.
|
@BartoszGrajdek We are testing on real devices, there is no modal. But I can see all the Preferences. az_recorder_20231129_075817.1.mp4 |
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.4.5-7 🚀
|




Details
Migrate 'CustomDevMenu' component file to TypeScript
Fixed Issues
$ #24978
Tests
On native:
Offline tests
QA Steps
On native:
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)/** comment above it */thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)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
Web
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android