RocketChat / RocketChat/Rocket.Chat.ReactNative
Update root component to React functional component.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.4k
- Forks
- 1.5k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 90
Description
Description:
The root component is currently implemented as a React class component. It should be updated to use a more modern functional component for consistency and to leverage hooks.
currently it looks like this
export default class Root extends React.Component<{}, IState> {
private listenerTimeout!: any;
private dimensionsListener?: EmitterSubscription
constructor(props: any) {
super(props);
this.init();
if (!isFDroidBuild) {
this.initCrashReport();
}
const { width, height, scale, fontScale } = Dimensions.get('window');
const theme = initialTheme();
this.state = {
theme: getTheme(theme),
themePreferences: theme,
width,
height,
scale,
fontScale
};
if (isTablet) {
this.initTablet();
}
setNativeTheme(theme);
}
Additional context:
In the future, all components using class components should migrate to functional components to align with modern React practices.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the root component implementation in the repository and review its initialization, lifecycle behavior, dimensions handling, theme setup, tablet setup, and crash reporting. Convert it to a functional component while preserving the current startup behavior and verify the mobile application still builds and runs on its supported platforms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, react-native, typescript
- Domain
- frontend, mobile
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100