Skip to content

chore: replace react-native-restart with expo reloadAppAsync#7485

Open
diegolmello wants to merge 2 commits into
chore/rn-0.83-expo-55from
chore/deinterop-restart
Open

chore: replace react-native-restart with expo reloadAppAsync#7485
diegolmello wants to merge 2 commits into
chore/rn-0.83-expo-55from
chore/deinterop-restart

Conversation

@diegolmello

@diegolmello diegolmello commented Jul 10, 2026

Copy link
Copy Markdown
Member

Proposed changes

react-native-restart@0.0.22 is an unmaintained (0.0.x) legacy native module that only runs on RN's
New-Architecture interop layer, and it carries an Android build.gradle patch just to build. This
replaces it with reloadAppAsync from the expo package — a new-arch-native app reload exposed by
expo-modules-core (already installed as a core dependency; no expo-updates needed).

  • app/views/LanguageView/index.tsx: the sole call site — swap RNRestart.Restart() for
    reloadAppAsync('Language RTL change') (fires only on an RTL⇄LTR language switch, where a hard
    native reload is required for I18nManager to flip).
  • Drop the react-native-restart dependency, delete patches/react-native-restart+0.0.22.patch, and
    remove its declare module entry from app/externalModules.d.ts.

One fewer unmaintained module riding the interop layer.

Issue(s)

Part of the RN 0.83 / Expo 55 interop-hardening effort under https://rocketchat.atlassian.net/browse/NATIVE-1234

How to test or reproduce

  1. Open Settings → Language.
  2. Switch to an RTL language (e.g. العربية / עברית) — the app hard-reloads and flips to RTL layout.
  3. Switch back to an LTR language — it hard-reloads back to LTR.

Verified on Android (Pixel API 34, arm64): the app builds with the module + patch removed, boots
cleanly, and the reload primitive (globalThis.expo.reloadAppAsync) hard-reloads the app in the
running bundle.

Screenshots

Types of changes

  • Improvement (non-breaking change which improves a current function)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • I have added necessary documentation (if applicable)
  • Any dependent changes have been merged and published in downstream modules

Further comments

Targets the RN 0.83 / Expo 55 integration branch (chore/rn-0.83-expo-55, #7481), not develop
reloadAppAsync and the surrounding Expo 55 setup only exist there. expo-updates' reloadAsync()
was rejected as heavyweight (it pulls the whole OTA-updates module for a reload the core runtime
already provides for free).

Summary by CodeRabbit

  • Bug Fixes

    • Improved automatic language selection to choose the best available language match.
    • Fixed language switching between left-to-right and right-to-left languages by reliably reloading the app when needed.
    • Updated localization support for improved compatibility with current language settings.
  • Maintenance

    • Removed an obsolete app restart integration and refreshed related platform configuration.

react-native-restart@0.0.22 is an unmaintained legacy interop-only native
module carrying an Android build.gradle patch. Expo (already a dep) exposes
reloadAppAsync via expo-modules-core — a new-arch-native app reload. Swap the
single call site (LanguageView RTL switch), drop the dep, patch, and type decl.
@diegolmello diegolmello temporarily deployed to approve_e2e_testing July 10, 2026 18:43 — with GitHub Actions Inactive
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ad384bc2-97fc-47ce-9aef-13f49ea8f696

📥 Commits

Reviewing files that changed from the base of the PR and between a32e82a and b65eb44.

⛔ Files ignored due to path filters (2)
  • ios/Podfile.lock is excluded by !**/*.lock
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • __mocks__/react-native-localize.js
  • app/externalModules.d.ts
  • app/i18n/index.ts
  • app/views/LanguageView/index.tsx
  • package.json
  • patches/react-native-restart+0.0.22.patch
💤 Files with no reviewable changes (2)
  • patches/react-native-restart+0.0.22.patch
  • app/externalModules.d.ts
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,jsx,tsx}: Use descriptive names for functions, variables, and classes that clearly convey their purpose
Write comments that explain the 'why' behind code decisions, not the 'what'
Keep functions small and focused on a single responsibility
Use const by default, let when reassignment is needed, and avoid var
Prefer async/await over .then() chains for handling asynchronous operations
Use explicit error handling with try/catch blocks for async operations
Avoid deeply nested code; refactor complex logic into helper functions

Files:

  • __mocks__/react-native-localize.js
  • app/views/LanguageView/index.tsx
  • app/i18n/index.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Use the project's ESLint setup (@rocket.chat/eslint-config with React, React Native, TypeScript, and Jest plugins) for code quality and style compliance

Files:

  • __mocks__/react-native-localize.js
  • app/views/LanguageView/index.tsx
  • app/i18n/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript for type safety; add explicit type annotations to function parameters and return types
Prefer interfaces over type aliases for defining object shapes in TypeScript
Use enums for sets of related constants rather than magic strings or numbers

**/*.{ts,tsx}: Use TypeScript in strict mode, with imports resolved from the app/ baseUrl
Follow the repository's TypeScript/React Native code style enforced by Prettier: tabs, single quotes, 130-character width, no trailing commas, omit arrow-function parens when possible, and keep brackets on the same line

Files:

  • app/views/LanguageView/index.tsx
  • app/i18n/index.ts
app/views/**/*.tsx

📄 CodeRabbit inference engine (CLAUDE.md)

Place screen components under app/views/

Files:

  • app/views/LanguageView/index.tsx
app/i18n/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Keep localization logic in app/i18n/, including i18n-js setup and RTL support

Files:

  • app/i18n/index.ts
🧠 Learnings (5)
📚 Learning: 2026-04-30T17:07:51.020Z
Learnt from: diegolmello
Repo: RocketChat/Rocket.Chat.ReactNative PR: 7274
File: app/lib/services/voip/MediaCallEvents.ts:0-0
Timestamp: 2026-04-30T17:07:51.020Z
Learning: In this Rocket.Chat React Native codebase, the ESLint rule `no-void: error` is enforced. When you see a promise returned from an async call that is not awaited (a “floating promise”), do not silence it with the `void somePromise()` pattern. Instead, handle the promise explicitly by attaching `.catch(...)` (or otherwise awaiting/handling the error) so unhandled-rejection risks are addressed in a way that satisfies the existing ESLint configuration.

Applied to files:

  • app/views/LanguageView/index.tsx
  • app/i18n/index.ts
📚 Learning: 2026-06-24T22:58:43.390Z
Learnt from: Rohit3523
Repo: RocketChat/Rocket.Chat.ReactNative PR: 7157
File: app/views/MessagesView/index.tsx:392-392
Timestamp: 2026-06-24T22:58:43.390Z
Learning: When wrapping a React Native component (e.g., via `withSafeAreaInsets`) ensure `hoistNonReactStatics` is only required if the wrapped component actually defines static properties/methods that consumers rely on. If the component has no statics (as in `app/views/MessagesView/index.tsx`), you can omit `hoistNonReactStatics` for this case.

Applied to files:

  • app/views/LanguageView/index.tsx
📚 Learning: 2026-06-25T18:37:44.793Z
Learnt from: diegolmello
Repo: RocketChat/Rocket.Chat.ReactNative PR: 7434
File: app/views/ScreenLockConfigView.tsx:101-141
Timestamp: 2026-06-25T18:37:44.793Z
Learning: In the Rocket.Chat React Native codebase, do not treat passing an `async` function directly to an event prop in React/React Native UI components (e.g., `onPress={async () => ...}` in TSX) as a “floating promises” CI-blocking lint issue—this repo does not enable the ESLint `no-floating-promises` rule (while `no-void` is enforced). Only raise robustness follow-ups when there are genuinely unhandled promise paths (e.g., fire-and-forget calls like `save()` that return a Promise that is neither awaited nor handled), and prefer making sure failure paths are explicitly handled/reported rather than blocking on lint-style floating-promise concerns.

Applied to files:

  • app/views/LanguageView/index.tsx
📚 Learning: 2026-02-05T13:55:00.974Z
Learnt from: Rohit3523
Repo: RocketChat/Rocket.Chat.ReactNative PR: 6930
File: package.json:101-101
Timestamp: 2026-02-05T13:55:00.974Z
Learning: In this repository, the dependency on react-native-image-crop-picker should reference the RocketChat fork (RocketChat/react-native-image-crop-picker) with explicit commit pins, not the upstream ivpusic/react-native-image-crop-picker. Update package.json dependencies (and any lockfile) to point to the fork URL and a specific commit, ensuring edge-to-edge Android fixes are included. This pattern should apply to all package.json files in the repo that declare this dependency.

Applied to files:

  • package.json
📚 Learning: 2026-05-07T17:47:14.516Z
Learnt from: diegolmello
Repo: RocketChat/Rocket.Chat.ReactNative PR: 7303
File: package.json:5-5
Timestamp: 2026-05-07T17:47:14.516Z
Learning: When reviewing pnpm `packageManager` version pins in any `package.json` (e.g., `"packageManager": "pnpm@<version>"`), don’t rely solely on web-search results to determine whether a version exists. For very recently published versions, cross-check the target version against the official pnpm release page (https://github.com/pnpm/pnpm/releases) and the npm registry page for pnpm (https://www.npmjs.com/package/pnpm) before flagging the pinned version as non-existent.

Applied to files:

  • package.json
🔇 Additional comments (6)
package.json (2)

114-116: 🩺 Stability & Availability

Check the dependency removals don’t leave stale references.

react-native-reanimated and react-native-restart should be absent from both imports and any build/runtime references before merging.


107-107: No API compatibility issue here. react-native-localize@3.7.0 exports findBestLanguageTag, and its return shape is { languageTag: string; isRTL: boolean } | undefined.

			> Likely an incorrect or invalid review comment.
__mocks__/react-native-localize.js (1)

2-2: 📐 Maintainability & Code Quality

Check for remaining findBestAvailableLanguage imports
The mock export was renamed to findBestLanguageTag; any test still importing findBestAvailableLanguage will now get undefined.

app/views/LanguageView/index.tsx (2)

1-1: 🎯 Functional Correctness

Keep the reloadAppAsync import from expo. It is exported there in SDK 55, so this import is fine.

			> Likely an incorrect or invalid review comment.

58-58: 🩺 Stability & Availability

Add a fallback for reloadAppAsync failures. If this promise rejects here, the app can remain in ROOT_LOADING without recovery.

app/i18n/index.ts (1)

185-185: 🎯 Functional Correctness

Remove this warning findBestLanguageTag returns { languageTag, isRTL } | undefined, so this destructuring matches the API shape.

			> Likely an incorrect or invalid review comment.

Walkthrough

Updates React Native localization matching to the newer API and mock, replaces RTL language restart handling with Expo app reload, adjusts ambient declarations, upgrades react-native-localize, and removes react-native-reanimated from dependencies.

Changes

Localization and runtime integration

Layer / File(s) Summary
Language matching API migration
package.json, __mocks__/react-native-localize.js, app/i18n/index.ts
Upgrades react-native-localize, changes the mock export, and uses findBestLanguageTag for initial language selection.
RTL reload integration
app/views/LanguageView/index.tsx, app/externalModules.d.ts, patches/react-native-restart+0.0.22.patch, package.json
Uses Expo’s reloadAppAsync for RTL changes, updates ambient module declarations, changes the restart patch repository, and removes react-native-reanimated.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: type: feature

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: replacing react-native-restart with Expo reloadAppAsync.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

package.json

Parsing error: Missing semicolon. (2:7)

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (2)
  • NATIVE-1234: Request failed with status code 401
  • EXPO-55: Request failed with status code 401

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant