Skip to content

Latest commit

 

History

History
 
 

RNWinRTTestApp

React Native WinRT Sample

This sample demonstrates how to use the react-native-winrt package to consume projected WinRT APIs with Javascript in a React Native for Windows app.

The WinRT APIs demonstrated in this sample include:

  • Windows.UI.StartScreen
  • Windows.Foundation.Uri
  • Windows.Storage
  • Windows.Foundation.Diagnostics
  • Windows.UI.Notifications

Prerequisites

Building and running the sample

  1. Open an 'x64 Native Tools Command Prompt for VS 2022' (or whichever version of Visual Studio you have installed)

  2. Clone or download the react-native-winrt repository.

    C:\> git clone https://github.com/microsoft/react-native-winrt.git
    C:\> cd react-native-winrt
  3. "Build" the local package by executing the script:

    C:\react-native-winrt> scripts\build-npm-package.cmd
  4. Change the working directory to this directory

    C:\react-native-winrt> cd samples\RNWinRTTestApp
  5. Run yarn install

    C:\react-native-winrt\samples\RNWinRTTestApp> yarn install

    NOTE: Because this project references local file contents for the react-native-winrt package, you must run yarn install as opposed to npm install, otherwise you may get build errors

  6. If using the command line:

    C:\react-native-winrt\samples\RNWinRTTestApp> npx react-native run-windows

    If using Visual Studio:

    • Open the solution file \windows\RNWinRTTestApp.sln in Visual Studio.
    • Build the solution.
    • If running Debug: run yarn start in the command prompt from this directory.
    • F5 deploy the sample app (RNWinRTTestApp).

You will see something similar to below after successfully building and running the sample:

Sample app