Skip to content

feat(windows): support react-native-windows new architecture#3708

Open
PHILLIPS71 wants to merge 26 commits intosoftware-mansion:mainfrom
PHILLIPS71:feat/windows-new-arch
Open

feat(windows): support react-native-windows new architecture#3708
PHILLIPS71 wants to merge 26 commits intosoftware-mansion:mainfrom
PHILLIPS71:feat/windows-new-arch

Conversation

@PHILLIPS71
Copy link
Copy Markdown

@PHILLIPS71 PHILLIPS71 commented Mar 2, 2026

Description

The Windows build for react-native-screens has been broken for consumers using autolinking, as reported in #3589.

The root cause is that the library's Windows native module was built against react-native-windows@0.64, which is long out of date and incompatible with current New Architecture tooling. This manifested as a linker error (LNK1104 win10-\) caused by autolinking discovering the legacy .sln files that include Microsoft.ReactNative.vcxproj, leaving $(Platform) unresolved.

This PR fixes the autolinking issue and fully migrates the Windows native layer to the Fabric (New Architecture) component model required by react-native-windows@0.81.

Closes #3589.

Changes

Autolinking fix

  • Added explicit windows platform config in react-native.config.js pointing autolinking only at RNScreens\RNScreens.vcxproj (no solution file), preventing the legacy .sln files from being auto-discovered and causing the $(Platform) linker error

react-native-windows upgrade

  • Upgraded react-native-windows from ^0.64.8 to ^0.81.4
  • Regenerated native module scaffold against react-native-windows@0.81.4; switches from the legacy UWP property sheets (Microsoft.ReactNative.Uwp.CppLib.*) to the new arch ones (Microsoft.ReactNative.CppLib.*)

Fabric migration
react-native-windows 0.81 removes the Paper renderer entirely. The IViewManager* interface family no longer exists. All Paper ViewManager classes and their XAML base classes have been replaced with the Fabric AddViewComponent / builder / UserData pattern.

Removed Paper
All *ViewManager classes (ScreenViewManager, ScreenStackViewManager, ScreenContainerViewManager, ScreenStackHeaderConfigViewManager, ScreenStackHeaderSubviewViewManager, ModalScreenViewManager, SearchBarViewManager) and their associated XAML base classes.

Added Fabric

File Role
Screen.h/.cpp ScreenProps, ScreenEventEmitter, ScreenUserData, and RegisterScreenLike helper shared by Screen and ModalScreen
ModalScreen.h/.cpp Thin wrapper, delegates to RegisterScreenLike with "RNSModalScreen"
ScreenStack.h/.cpp Registers RNSScreenStack with onFinishTransitioning emitter infrastructure
ScreenContainer.h/.cpp Registers RNSScreenContainer; no custom props per spec
ScreenStackHeaderConfig.h/.cpp Stub registration, see Notes
ScreenStackHeaderSubview.h/.cpp Stub registration, see Notes
SearchBar.h/.cpp Stub registration, see Notes
BaseProps.h Shared minimal IComponentProps for stub components; required by the Fabric framework to safely deliver base ViewProps

Updated:

  • ReactPackageProvider.cpp replaces AddViewManager calls with IReactPackageBuilderFabric; falls back gracefully on non-Fabric hosts

Lifecycle events
The old implementation dispatched onWillAppear, onAppear, onWillDisappear, and onDisappear from XAML Loading, Loaded, and Unloaded events. Fabric has no pre-mount hook, so onWillAppear + onAppear are both dispatched from ComponentView::Mounted, and onWillDisappear + onDisappear from ComponentView::Unmounted.

The Will* events are co-incident with their counterparts on Windows. This matches the old behaviour for Disappear (the old Unloaded handler also fired both synchronously) and is an acknowledged approximation for WillAppear.

Notes

  • Native version downgrade: react-native devDependency is downgraded from 0.84.0 to 0.81.5 to match react-native-windows@0.81.4. The peer dependency floor is also lowered from >=0.82.0 to >=0.81.0

  • Stub components: ScreenStackHeaderConfig, ScreenStackHeaderSubview, and SearchBar are registered as stubs. The previous implementation was also non-functional for these components (empty XAML StackPanel with no props applied or events fired). A non-empty stub registration is required, an empty builder lambda causes the Fabric framework to crash when delivering props. Native implementations are tracked as follow-up work.

  • react-native-restart: was removed as it doesn't support the new architecture

Known gaps (follow-up work):

  • stackAnimation and replaceAnimation are accepted and stored but not applied; no native transition animations exist on Windows yet
  • ScreenStackHeaderConfig / ScreenStackHeaderSubview require a Windows title bar strategy before they can be implemented; SearchBar maps naturally to WinUI AutoSuggestBox and is a self-contained follow-up

@kkafar
Copy link
Copy Markdown
Member

kkafar commented Mar 2, 2026

Thanks for the PR, that's awesome. Tag me once it is ready for review.

@PHILLIPS71 PHILLIPS71 marked this pull request as ready for review March 3, 2026 08:43
@PHILLIPS71
Copy link
Copy Markdown
Author

@kkafar ready for a first pass whenever you get a chance!

One thing worth discussing: the existing windows-build-test.yml dynamically creates a fresh example app on every CI run, it queries npm for the latest react-native-windows version, spins up a matching RN project, builds it, then throws it away. It works, but there's no committed WindowsExample/ in the repo the way FabricExample/ exists for iOS and Android.

Should we instead commit a concrete WindowsExample/ and simplify the pipeline to just build it directly? It would be consistent with how the other platforms work and give contributors something to actually run. The trade-off is that react-native-windows tends to trail react-native releases by a minor version, so it would need to pin a different RN version than FabricExample/ and require a periodic update when RNW catches up.

Copy link
Copy Markdown
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

I've left initial notes. I haven't gone through the component code yet, but I've reviewed surrounding changes.

Comment thread src/core.ts Outdated
Comment thread apps/src/screens/Gestures.tsx
Comment thread apps/Example.tsx Outdated
Comment thread TVOSExample/App.tsx
Comment thread TVOSExample/package.json
Comment thread windows/RNScreens/ModalScreen.h Outdated
Comment thread windows/RNScreens/pch.cpp Outdated
Comment thread package.json Outdated
Comment thread package.json Outdated
"peerDependencies": {
"react": "*",
"react-native": ">=0.82.0"
"react-native": ">=0.81.0"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can not be lowered. We've just recently started using peerDependencies explicitly (see here) and it's meant to denote lowest supported version according to our policy. It's 0.82 since not-yet-released 4.25.0.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see it might be problematic :/ I'll ask some people internally whether it would be possible for us to go back to react-native: "*".

Comment thread package.json Outdated
"react": "19.2.3",
"react-dom": "^19.1.0",
"react-native": "0.84.0",
"react-native": "0.81.5",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also should not be changed. We keep the dev library dependencies up-to-date so that we can react to changes in the react-native core & report issues there when necessary.

Copy link
Copy Markdown
Author

@PHILLIPS71 PHILLIPS71 Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The downgrade was necessary because react-native-windows trails behind react-native's versioning. react-native-windows@0.81.4 only supports react-native@0.81.x, and 0.84 is not yet supported upstream. This also caused the peer dependency range to drop from >=0.82.0 to >=0.81.0, which I agree is not ideal.

@kkafar
Copy link
Copy Markdown
Member

kkafar commented Mar 3, 2026

Regarding the question about WindowsExample you asked - I consider it. I do not remember exact rationale, but IIRC we had an windows example at some point (?), but no one to really maintain it. So my answer here depends on whether we can find a maintainer for that part of the codebase. The "core team at SWM" is now heavily invested in the "in-tree platforms" and this won't change for many more months to come.

@kkafar kkafar requested a review from Copilot March 3, 2026 21:21
@kkafar kkafar self-assigned this Mar 3, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the Windows native implementation of react-native-screens to work with current react-native-windows New Architecture (Fabric) tooling and removes legacy Windows solution artifacts that were being picked up by autolinking and breaking consumers.

Changes:

  • Migrates the Windows native layer from legacy Paper IViewManager*/XAML-based managers to Fabric AddViewComponent registrations (with several components currently stubbed).
  • Upgrades Windows dev tooling/dependencies to react-native-windows@^0.81.4 and regenerates the Windows C++/WinRT project structure.
  • Removes old Windows solution files and adjusts examples to avoid unsupported dependencies (e.g., react-native-restart, gesture-handler on Windows).

Reviewed changes

Copilot reviewed 58 out of 64 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
windows/RNScreens65.sln Removes legacy solution that could be auto-discovered by autolinking.
windows/RNScreens63.sln Removes legacy solution that could be auto-discovered by autolinking.
windows/RNScreens62.sln Removes legacy solution that could be auto-discovered by autolinking.
windows/RNScreens/targetver.h Adds standard Windows SDK targeting header for the regenerated project.
windows/RNScreens/resource.h Adds resource header for the regenerated project.
windows/RNScreens/pch.h Updates precompiled header to new RNW 0.81+ includes and WinUI composition headers.
windows/RNScreens/pch.cpp Normalizes PCH compilation unit.
windows/RNScreens/packages.lock.json Adds NuGet lock for RNW 0.81+ dependencies.
windows/RNScreens/codegen/NativeScreensModuleSpec.g.h Adds Windows codegen output for the TurboModule spec.
windows/RNScreens/codegen/.clang-format Disables formatting in codegen output directory.
windows/RNScreens/SearchBarViewManager.h Removes legacy Paper view manager implementation.
windows/RNScreens/SearchBarViewManager.cpp Removes legacy Paper view manager implementation.
windows/RNScreens/SearchBar.h Converts SearchBar to Fabric stub registration API.
windows/RNScreens/SearchBar.cpp Registers SearchBar as a Fabric stub component.
windows/RNScreens/ScreenViewManager.h Removes legacy Paper view manager implementation.
windows/RNScreens/ScreenViewManager.cpp Removes legacy Paper view manager implementation.
windows/RNScreens/ScreenStackViewManager.h Removes legacy Paper view manager implementation.
windows/RNScreens/ScreenStackViewManager.cpp Removes legacy Paper view manager implementation.
windows/RNScreens/ScreenStackHeaderSubviewViewManager.h Removes legacy Paper view manager implementation.
windows/RNScreens/ScreenStackHeaderSubviewViewManager.cpp Removes legacy Paper view manager implementation.
windows/RNScreens/ScreenStackHeaderSubview.h Converts header subview to Fabric stub registration API.
windows/RNScreens/ScreenStackHeaderSubview.cpp Registers header subview as a Fabric stub component.
windows/RNScreens/ScreenStackHeaderConfigViewManager.h Removes legacy Paper view manager implementation.
windows/RNScreens/ScreenStackHeaderConfigViewManager.cpp Removes legacy Paper view manager implementation.
windows/RNScreens/ScreenStackHeaderConfig.h Converts header config to Fabric stub registration API.
windows/RNScreens/ScreenStackHeaderConfig.cpp Registers header config as a Fabric stub component.
windows/RNScreens/ScreenStack.h Converts ScreenStack to Fabric stub registration API.
windows/RNScreens/ScreenStack.cpp Registers ScreenStack as a Fabric stub component.
windows/RNScreens/ScreenContainerViewManager.h Removes legacy Paper view manager implementation.
windows/RNScreens/ScreenContainerViewManager.cpp Removes legacy Paper view manager implementation.
windows/RNScreens/ScreenContainer.h Converts ScreenContainer to Fabric stub registration API.
windows/RNScreens/ScreenContainer.cpp Registers ScreenContainer as a Fabric stub component.
windows/RNScreens/Screen.h Replaces legacy XAML Screen class with Fabric registration entrypoints.
windows/RNScreens/Screen.cpp Implements Fabric RNSScreen behavior (activityState visibility + lifecycle event forwarding).
windows/RNScreens/ReactPackageProvider.idl Renames WinRT namespace to ReactNativeScreens.
windows/RNScreens/ReactPackageProvider.h Updates provider namespace and method signature formatting.
windows/RNScreens/ReactPackageProvider.cpp Switches to Fabric registration via IReactPackageBuilderFabric and registers components.
windows/RNScreens/RNScreens.vcxproj.filters Regenerated filters file for the new project structure.
windows/RNScreens/RNScreens.vcxproj Regenerated RNW 0.81.4 C++ library project and dependencies.
windows/RNScreens/RNScreens.rc Adds resource script for the regenerated project.
windows/RNScreens/RNScreens.h Adds Windows TurboModule scaffolding header (currently mismatched vs JS module name).
windows/RNScreens/RNScreens.cpp Adds Windows TurboModule scaffolding implementation.
windows/RNScreens/ModalScreenViewManager.h Removes legacy Paper view manager implementation.
windows/RNScreens/ModalScreenViewManager.cpp Removes legacy Paper view manager implementation.
windows/RNScreens/ModalScreen.h Adds Fabric registration API for modal screen wrapper.
windows/RNScreens/ModalScreen.cpp Registers modal screen behavior via shared RegisterScreenLike.
windows/RNScreens/BaseProps.h Adds shared “stub” props + stub component registration helper.
windows/RNScreens.sln Adds a new RNW 0.81+ solution file.
windows/ExperimentalFeatures.props Enables RNW New Architecture + experimental NuGet mode for the Windows solution build.
windows/.gitignore Updates ignored artifacts for modern Visual Studio/RNW builds.
src/core.ts Updates native linking check to use UIManager.hasViewManagerConfig.
package.json Includes Windows output in published files + updates RN/RNW versions and adds Windows codegen config.
apps/src/screens/Gestures.tsx Removes react-native-restart usage from example screen.
apps/Example.tsx Avoids gesture-handler usage on Windows by dynamically requiring and adding Windows fallbacks.
TVOSExample/yarn.lock Removes react-native-restart resolution from tvOS example lockfile.
TVOSExample/package.json Removes react-native-restart from tvOS example dependencies.
TVOSExample/ios/Podfile.lock Removes react-native-restart pod references.
TVOSExample/App.tsx Simplifies re-export.
README.md Updates Windows installation notes to reflect Fabric-only / RNW 0.81+ requirement.
NuGet.config Adds NuGet feeds needed for RNW public packages.
FabricExample/yarn.lock Removes react-native-restart resolution from Fabric example lockfile.
FabricExample/package.json Removes react-native-restart from Fabric example dependencies.
FabricExample/ios/Podfile.lock Removes react-native-restart pod references.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread windows/RNScreens/RNScreens.vcxproj Outdated
Comment thread windows/RNScreens/BaseProps.h
Comment thread package.json Outdated
Comment thread package.json Outdated
Comment thread apps/src/screens/Gestures.tsx
Comment thread windows/RNScreens/RNScreens.h Outdated
Comment thread apps/Example.tsx Outdated
Comment thread windows/RNScreens/RNScreens.vcxproj.filters
@PHILLIPS71
Copy link
Copy Markdown
Author

Thanks @kkafar, I've reverted the removal of react-native-restart and used an interop file that will become a non-op in Windows, there is https://github.com/ahmedawaad1804/react-native-restart-newarch that supports the new architecture, though it can probably be handled in a separate pr.

@tux2nicolae
Copy link
Copy Markdown

@PHILLIPS71 thank you for your work, and thanks kkafar for review-ing it.

With the release of react-native-windows 0.82.0 which targets the 0.82.0 i think the peer dependency min version problem is solved by itself ?

We're waiting for windows support as well for a while and this PR gives us some hope

# Conflicts:
#	apps/src/screens/Gestures.tsx
#	package.json
#	yarn.lock
@PHILLIPS71
Copy link
Copy Markdown
Author

@tux2nicolae I believe so, I've update the branch against main and updates to react-native-windows@0.82.3 so this PR doesn't become stale.

@tux2nicolae
Copy link
Copy Markdown

@PHILLIPS71 that's awesome, thx, @kkafar when you find some time can you review this one more time please?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Projects with this package fail to build for Windows

4 participants