Moving from .NET MAUI to React Native is not an upgrade. It is a rewrite in another language, and none of the C# survives. That makes one question more important than any other: what tells you that the new app does what the old one did? This case contains a .NET MAUI app, the same app written in React Native, and the old app’s test scenarios ported to run against the new screens.
The code is on GitHub: chudovo/application-modernization, case 04. The starting point is the .NET MAUI app from the Xamarin.Forms to .NET MAUI case, and the service it talks to comes from the WCF to Web API case.
At a glance
| Before | After | |
|---|---|---|
| Framework | .NET MAUI on .NET 10 | React Native 0.88 with Expo SDK 58 |
| Language | C# and XAML | TypeScript |
| Screen logic | view models with commands and bindings | function components with hooks |
| Dependencies | constructor injection | one services object in React context |
| Navigation | Shell routes | React Navigation native stack |
| Messaging between screens | typed messages through IMessenger | a small typed event |
| Settings on the device | Preferences | AsyncStorage, filled once from the old store |
| Tests | xUnit against view models | Jest against rendered screens |
What carries over when no code does
Four things survive a rewrite, and the case is built around them:
- The scenarios. The 11 screen-level scenarios from the previous case describe what the app does, not how it is built. They are the specification for the new app.
- The API contract. The service is not touched. The new app sends the same requests and has to cope with the same answers, including a conflict when someone else changed a shipment.
- The app identity. The application identifier stays the same, so the stores deliver the new app as an update to the old one.
- What is stored on the device. The device identity and the offline cache written by the old app must still be there after the update.
Step 1: port the scenarios, not the code
In the .NET MAUI version the scenarios drive view models. React Native has no view models to drive, so the ported scenarios work one level higher: they render the real app with its navigation and all three screens, then press, type and read what is on screen. Here is the same scenario in both versions:
// .NET MAUI: the scenario drives view models
await app.Run(app.List.OpenCommand, app.List.Items[1]);
await app.Appear();
await app.Run(app.Detail.MarkDeliveredCommand);
Assert.Equal("Delivered", app.Detail.StatusLabel);
Assert.Equal("Delivered 2026-02-10 12:00 UTC", app.Detail.DeliveredText);
Assert.Equal("Delivered", app.List.Items[1].Status);
// React Native: the same scenario drives the rendered screens
await fireEvent.press(screen.getByTestId('shipment-SHP-000002'));
await screen.findByText('Jean Martin');
await press('Mark delivered');
await waitFor(() => expect(screen.getByTestId('status')).toHaveTextContent('Delivered'));
expect(screen.getByTestId('delivered')).toHaveTextContent('Delivered 2026-02-10 12:00 UTC');
await waitFor(() => expect(row('SHP-000002').getByText('Lyon, FR · Delivered')).toBeTruthy());
As before, the API is not faked. A small helper starts a fresh copy of the real shipment service for each test, and the app talks to it over HTTP. Only four device-level things are replaced in tests: connectivity, key-value storage, dialogs and the device locale.
Step 2: the screens
Each view model and its XAML page become one function component. The interfaces that the .NET MAUI app resolved through dependency injection become one object passed through React context, which is what lets the tests swap the device-level parts:
// Everything a screen needs from outside, passed through React context.
// The app supplies real implementations, the tests supply their own.
export interface Services {
api: ShipmentApi;
network: { isOnline(): Promise<boolean> };
settings: { get(key: string): Promise<string | null>; set(key: string, value: string): Promise<void> };
dialogs: { alert(message: string): Promise<void> };
locale(): string;
}
export function ShipmentListScreen({ navigation }: ScreenProps<'Shipments'>) {
const { api, network, settings } = useServices();
const [items, setItems] = useState<Shipment[]>([]);
const [filter, setFilter] = useState<StatusFilter>('All');
// ...
// Loads when the screen comes into view and again when the filter changes.
useFocusEffect(useCallback(() => { void load(); }, [load]));
}
The translation is mostly direct:
| .NET MAUI | React Native |
|---|---|
| ObservableProperty, bindings in XAML | useState and JSX |
| RelayCommand | a function passed to onPress |
| OnAppearing calling the load command | useFocusEffect |
| CollectionView with RefreshView | FlatList with RefreshControl |
| Shell.GoToAsync with a route parameter | navigation.navigate with typed params |
| IMessenger.Send(new ShipmentChangedMessage()) | shipmentChanged.emit() |
| Connectivity.Current.NetworkAccess | NetInfo.fetch() |
| System.Text.Json with web defaults | the JSON is already in the shape the screens use |
Where a direct translation is wrong
Two pieces of the new app exist only because a line-by-line translation of the C# does not behave the same. Take them out of the finished app and three of the eleven scenarios fail.
The decimal comma. On a German phone a user types a weight as 2,5. In C# the form called decimal.TryParse with the device culture and that was the end of it. In JavaScript, Number(“2,5”) is NaN on every device, whatever its language. With Number in the form, the scenario for a German device fails, so the app has its own parsing:
// .NET: decimal.TryParse(text, culture) reads "2,5" on a German phone.
// JavaScript: Number("2,5") is NaN on every device, so the separator is taken from the locale.
export function parseLocalDecimal(text: string | undefined, locale: string): number | null {
if (!text) return null;
const parts = new Intl.NumberFormat(locale).formatToParts(12345.6);
const decimal = parts.find((p) => p.type === 'decimal')?.value ?? '.';
const group = parts.find((p) => p.type === 'group')?.value ?? '';
let normalized = text.trim();
if (group) normalized = normalized.split(group).join('');
normalized = normalized.replace(decimal, '.');
if (!/^[+-]?\d+(\.\d+)?$/.test(normalized)) return null;
return Number(normalized);
}
This is the kind of difference that reaches users when nobody ported the scenario: a developer’s phone and typical test data use a decimal point.
The list behind the detail screen. The scenario marks a shipment as delivered and then checks that the list behind the detail screen shows the new status. A native stack keeps the previous screen mounted, so the list does not reload when the user goes back. It has to be told about the change, which is what the event between screens is for. Without the subscription, this scenario and the one that creates a shipment fail. The old app had the same requirement and solved it with a message.
Step 3: what the old app left on the device
This is the part a rewrite forgets most easily. The .NET MAUI app kept the device identity and the offline cache in an Android preferences file named parceltracker. JavaScript storage libraries use their own files and cannot see it. Reading it takes a few lines of native code:
// Kotlin, 20 lines: the only way to see the file the old app wrote.
class LegacySettingsModule : Module() {
override fun definition() = ModuleDefinition {
Name("LegacySettings")
AsyncFunction("getString") { key: String ->
val context = appContext.reactContext ?: throw Exceptions.ReactContextLost()
context.getSharedPreferences("parceltracker", Context.MODE_PRIVATE).getString(key, null)
}
}
}
The second half is in TypeScript. The old app wrote its cache with .NET’s default JSON settings, so property names are in PascalCase and two computed properties are included. The new app expects the camelCase shape the API returns, so the cache is converted on the way:
// TypeScript: runs once, on the first start after the update.
export async function migrateLegacySettings(legacy: LegacyStore | null, settings: KeyValueStore): Promise<void> {
if ((await settings.get('legacy.migrated')) === 'true') return;
if (legacy) {
const clientId = await legacy.getString('client.id');
if (clientId && !(await settings.get('client.id'))) await settings.set('client.id', clientId);
const cache = await legacy.getString('shipments.cache');
if (cache && !(await settings.get('shipments.cache'))) {
const converted = convertLegacyCache(cache); // PascalCase from .NET to the camelCase the API returns
if (converted) await settings.set('shipments.cache', JSON.stringify(converted));
}
}
await settings.set('legacy.migrated', 'true');
}
The conversion and the run-once logic are covered by four tests that use a cache string in exactly the format the old app wrote. The native part is compiled into the Android and iOS builds but was not run on a phone, see below.
What is verified, and what is not
| Check | Result |
|---|---|
| 11 scenarios against the React Native screens and the real service | 11 / 11 |
| 4 tests of the settings migration | 4 / 4 |
| TypeScript type check in strict mode | passes |
| App builds for Android, with the native settings module inside | builds, the settings module is in the APK |
| App builds for the iOS simulator | builds, unsigned |
- Nothing was run on a device. The scenarios render the real screens and navigation in a test environment, not on a phone. Layout, gestures and the native reading of the old preferences file were not observed on a device. Before a release this needs one manual check: install the old app, create data, install the new build over it.
- The scenarios are ported, not shared. In the previous case one source file was compiled against both versions. Across two languages that is not possible. The eleven tests were rewritten by hand, one for one, with the same names, data and expected texts.
- Performance, app size and start-up time were not compared.
Two things went wrong in the test setup and are worth knowing. The test environment of Expo replaces the global fetch function, so tests that should talk to a real service get no network; the API client takes the fetch function as a parameter and the tests pass in one built on Node’s HTTP module. And in the current version of the React Native testing library, press and type events are asynchronous: a press fired without awaiting the preceding text change sees the old state, which first looked like a bug in the form.
Run it yourself
The tests need Node 22 and the .NET 10 SDK, which runs the service the app talks to. No phone, emulator or Android SDK is needed:
cd cases/04-maui-to-react-native/after
npm ci
npm test # 11 screen scenarios + 4 migration tests, starts the real service itself
npm run typecheck
Building the app for a device is described in the README of the case.
When this path fits
Leaving .NET MAUI for React Native costs a full rewrite of the client, so it needs a reason that an upgrade cannot give. The usual ones: the company already builds its web products in React and TypeScript and wants one team for web and mobile, or hiring for .NET mobile development has become the bottleneck. If the team works in .NET and the app works, staying on .NET MAUI is cheaper. The choice between these paths is covered in Mobile App Modernization: Choosing a Path for Xamarin, Native and Cross-Platform Apps.
If you need a team for a rewrite like this, see our comparison of top .NET modernization companies.