react-native-screens: Native Stack is not working with react-native-windows@0.76
Description
After a clean react-native-windows@0.76 installation followed by the recommended installation for the native stack from the Getting Started guide, I get the following build error:
× Building Solution: C:\dev\RNWTests\node_modules\react-native-screens\windows\RNScreens\RNScreens.vcxproj(184,5… × Build failed with message 7:10>C:\dev\RNWTests\node_modules\react-native-screens\windows\RNScreens\RNScreens.vcxproj(184,5): error : This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is C:\dev\RNWTests\windows\packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.props… Check your build configuration.
Steps to reproduce
- install clean react-native@0.76
- install and init react-native-windows@0.76
- install
@react-navigation/native,react-native-screens,react-native-safe-area-context,@react-navigation/native-stack,@react-navigation/elements - run
npx @react-native-community/cli run-windows
Snack or a link to a repository
https://github.com/pcprinz/react-native-windows-tests/tree/0.76-failing-native-stack
Screens version
4.3.0
React Native version
0.76.2
Platforms
Windows
JavaScript runtime
Hermes
Workflow
React Native (without Expo)
Architecture
Paper (Old Architecture)
Build type
None
Device
None
Device model
No response
Acknowledgements
Yes
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 40 (7 by maintainers)
No, I haven’t tended to this issue yet. Will update when I do
This auto-close thing is exactly what I see so it is reproducible at least! I did a bit more investigation of this and I think it is due to a class (
RNSScreenContentWrapper) which is not implemented for Windows yet. There are some details in this thread: https://github.com/microsoft/react-native-windows/discussions/14273#discussioncomment-11825178 (in a different repo as I thought the issue might be with react-native-windows itself) I’d like to help with this but there’s very little info I can glean from the iOS and Android implementations as to what the missing class(es) are supposed to do. Cloning this repo and runningyarn test:unitdoesn’t end well. Maybe some pointers from @kkafar and we could get started?@kkafar I see you have a lot of work with this library on Android and IOS and I don’t want to look mean, but we really need your help on this issue and here https://github.com/software-mansion/react-native-screens/issues/2649, it’s just a blocker for windows platform, we can’t build it at all
I encountered the same issue as #2649, but I haven’t been able to resolve it. This is a major blocker for the Windows platform…
@joshholmeszonal unfortunately I don’t have any additional context. Here’s the umbrella issue on
react-native-windowsrepo.We’re waiting here on @Yajur-Grover, @sharath2727 move - if there is anything to be done on
react-native-screensend, we’ll be able to give it some hours, however from the context I got it’s still down toreact-native-windowspackage.Are there any plans to upgrade the library to support the new architecture on Windows? if you could be kind and provide us some information so that it’s easy to decide whether to use it or not. Thanks 🙏
Please can you reconsider making react-native-screens support windows on new arch? It’s the last missing piece we need to deploy our app on windows.
@sharath2727 is there any rough timeline for this to be upgraded to the New Arch yet?
Hi sorry for the late reply - currently there is no issue published tracking the status of new arch upgrades for community modules. @sharath2727 is taking over ownership of the community modules, adding him to this thread in case there are any updates.
This does appear to have fixed the issue, thanks.
What I did was:
yarn add react-native-screens@4.11.0-beta.1yarn windowsand the app started as expected.
Hi, @pedro-w. The work is still in progress, some components are not ready yet. When we’ll manage to sort everything out, we’ll release a beta version with the changes so that people can test them out. Thank you for your patience.
Hi.
I managed to reproduce the error from the PR description, however running
npx react-native run-windowsfor the second time downloads necessary packages andreact-nativeExample app builds. You can also try to run NuGet package restore using methods from Microsoft’s docs.I confirm that after adding any
react-navigationcomponents, the app auto-closes. Somereact-native-screenscomponents are yet to be implemented for Windows platform and this probably causes the crash.I wasn’t able to reproduce issue https://github.com/software-mansion/react-native-screens/issues/2649 with
react-native@0.76.8,react-native-windows@0.76.9,react-native-screens@4.10.0on old architecture (Paper). If the error happens on new architecture (Fabric) as mentioned here, please note thatreact-native-screensis not supported for Farbic. See also @Yajur-Grover’s comment here. The same applies to issue https://github.com/software-mansion/react-native-screens/issues/2637.Here is a guide that can help you with getting started if you want to try and upgrade a module to use the new-arch: https://github.com/microsoft/react-native-windows/wiki/Upgrading-a-React-Native-Windows-TurboModule-to-use-the-New-Architecture.
However, this mainly applies to modules where the native code/implementation does not need to be changed and don’t have any custom UI components. Modules like
react-native-screensmay require some more complicated changes, but modules that are ‘non-UI’ would be able to be upgraded using the steps above.Looking at the dependencies, I tried various combinations and this one worked *
This is not quite the same as react-native-gallery - it has react-native-screens at ^2.9.0 but yarn gave peer dependency warnings that react-navigation needs r-n-s >= 3. (and I got errors if I ignored these warnings)
So I think something critical changed in r-n-s between versions 3 and 4.
* by which I mean the app started without any errors and didn’t immediately close again.
Hey - I took a look at the RNWTests branch again. Can you try and change your dependencies for
react-navigationandreact-native-screenspackages to what we have in react-native-gallery here and see if that resolves the issue? My guess is that the newer versions of react-navigation are using a component onreact-native-screensthat is unsupported on Windows. Let me know if the issue still persists.