feat(windows): support react-native-windows new architecture#3708
feat(windows): support react-native-windows new architecture#3708PHILLIPS71 wants to merge 26 commits intosoftware-mansion:mainfrom
Conversation
…sn't support react-native-windows
|
Thanks for the PR, that's awesome. Tag me once it is ready for review. |
# Conflicts: # Example/App.tsx # Example/metro.config.js # Example/package.json # Example/yarn.lock # TVOSExample/package.json # TVOSExample/yarn.lock
|
@kkafar ready for a first pass whenever you get a chance! One thing worth discussing: the existing Should we instead commit a concrete |
kkafar
left a comment
There was a problem hiding this comment.
Thanks for the PR!
I've left initial notes. I haven't gone through the component code yet, but I've reviewed surrounding changes.
| "peerDependencies": { | ||
| "react": "*", | ||
| "react-native": ">=0.82.0" | ||
| "react-native": ">=0.81.0" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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: "*".
| "react": "19.2.3", | ||
| "react-dom": "^19.1.0", | ||
| "react-native": "0.84.0", | ||
| "react-native": "0.81.5", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
Regarding the question about |
There was a problem hiding this comment.
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 FabricAddViewComponentregistrations (with several components currently stubbed). - Upgrades Windows dev tooling/dependencies to
react-native-windows@^0.81.4and 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.
|
Thanks @kkafar, I've reverted the removal of |
|
@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
|
@tux2nicolae I believe so, I've update the branch against |
|
@PHILLIPS71 that's awesome, thx, @kkafar when you find some time can you review this one more time please? |
Description
The Windows build for
react-native-screenshas 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.slnfiles that includeMicrosoft.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
windowsplatform config inreact-native.config.jspointing autolinking only atRNScreens\RNScreens.vcxproj(no solution file), preventing the legacy.slnfiles from being auto-discovered and causing the$(Platform)linker errorreact-native-windows upgrade
react-native-windowsfrom^0.64.8to^0.81.4react-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-windows0.81 removes the Paper renderer entirely. TheIViewManager*interface family no longer exists. All Paper ViewManager classes and their XAML base classes have been replaced with the FabricAddViewComponent/ builder / UserData pattern.Removed Paper
All
*ViewManagerclasses (ScreenViewManager,ScreenStackViewManager,ScreenContainerViewManager,ScreenStackHeaderConfigViewManager,ScreenStackHeaderSubviewViewManager,ModalScreenViewManager,SearchBarViewManager) and their associated XAML base classes.Added Fabric
Screen.h/.cppScreenProps,ScreenEventEmitter,ScreenUserData, andRegisterScreenLikehelper shared by Screen and ModalScreenModalScreen.h/.cppRegisterScreenLikewith"RNSModalScreen"ScreenStack.h/.cppRNSScreenStackwithonFinishTransitioningemitter infrastructureScreenContainer.h/.cppRNSScreenContainer; no custom props per specScreenStackHeaderConfig.h/.cppScreenStackHeaderSubview.h/.cppSearchBar.h/.cppBaseProps.hIComponentPropsfor stub components; required by the Fabric framework to safely deliver baseViewPropsUpdated:
ReactPackageProvider.cppreplacesAddViewManagercalls withIReactPackageBuilderFabric; falls back gracefully on non-Fabric hostsLifecycle events
The old implementation dispatched
onWillAppear,onAppear,onWillDisappear, andonDisappearfrom XAMLLoading,Loaded, andUnloadedevents. Fabric has no pre-mount hook, soonWillAppear+onAppearare both dispatched fromComponentView::Mounted, andonWillDisappear+onDisappearfromComponentView::Unmounted.The
Will*events are co-incident with their counterparts on Windows. This matches the old behaviour forDisappear(the oldUnloadedhandler also fired both synchronously) and is an acknowledged approximation forWillAppear.Notes
Native version downgrade:
react-nativedevDependency is downgraded from0.84.0to0.81.5to matchreact-native-windows@0.81.4. The peer dependency floor is also lowered from>=0.82.0to>=0.81.0Stub components:
ScreenStackHeaderConfig,ScreenStackHeaderSubview, andSearchBarare registered as stubs. The previous implementation was also non-functional for these components (empty XAMLStackPanelwith 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):
stackAnimationandreplaceAnimationare accepted and stored but not applied; no native transition animations exist on Windows yetScreenStackHeaderConfig/ScreenStackHeaderSubviewrequire a Windows title bar strategy before they can be implemented;SearchBarmaps naturally to WinUIAutoSuggestBoxand is a self-contained follow-up