RocketChat / RocketChat/Rocket.Chat.ReactNative

Update root component to React functional component.

Open
#6,031 4 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.