### Start Development Server Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/README.md Execute this command to start the local development server for the website. ```sh # Start the site $ yarn start ``` -------------------------------- ### Install Website Dependencies Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/README.md Run this command to install all necessary dependencies for the website. ```sh # Install dependencies $ yarn install ``` -------------------------------- ### Run Example App (New Architecture) Source: https://github.com/microsoft/react-native-windows-samples/blob/main/samples/NativeModuleSample/cpp-lib/README.md Execute this command to run the example app targeting the New Architecture and verify the native module. ```cmd yarn example windows ``` -------------------------------- ### Install Dependencies Source: https://github.com/microsoft/react-native-windows-samples/blob/main/samples/Calculator/cppwinrt/README.md Navigate into the newly created Calculator directory and install project dependencies using Yarn. ```cmd cd Calculator yarn install ``` -------------------------------- ### Install Module Dependencies Source: https://github.com/microsoft/react-native-windows-samples/blob/main/samples-old/NativeModuleSample/README.md Installs the necessary dependencies for the native module. Use yarn or npm based on your project setup. ```cmd yarn install ``` ```cmd npm install ``` -------------------------------- ### Run Example App (Old Architecture) Source: https://github.com/microsoft/react-native-windows-samples/blob/main/samples/NativeModuleSample/cpp-lib/README.md Use this command to run the old example app targeting the Old Architecture and verify the native module. ```cmd yarn example-old windows ``` -------------------------------- ### Run React Native Windows Example App Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/native-platform-getting-started.md Execute the command to run the React Native for Windows example app. This can be run from the example folder or the library's root. ```bat yarn react-native run-windows ``` -------------------------------- ### Start Metro Bundler Source: https://github.com/microsoft/react-native-windows-samples/blob/main/samples-old/AppServiceDemo/README.md Run this command in the project folder to start the Metro bundler, which is necessary for the special configuration of this sample. ```cmd yarn start ``` -------------------------------- ### Install Dependencies with Yarn Source: https://github.com/microsoft/react-native-windows-samples/blob/main/samples-old/AppServiceDemo/README.md Use this command to install project dependencies if you have Yarn installed. ```cmd yarn install ``` -------------------------------- ### Install Dependencies and Build TypeScript Source: https://github.com/microsoft/react-native-windows-samples/blob/main/samples/NativeModuleSample/cpp-lib/README.md Run these commands to install the module's dependencies and build the TypeScript files. ```cmd yarn install yarn prepare ``` -------------------------------- ### Install Dependencies with NPM Source: https://github.com/microsoft/react-native-windows-samples/blob/main/samples-old/AppServiceDemo/README.md Use this command to install project dependencies if you do not have Yarn installed. ```cmd npm install ``` -------------------------------- ### Start CoreApp with Callback Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/blog/2022-07-29-coreapp.md Use this C API to start a CoreApp. It calls back upon launch, allowing customization of parameters like bundle name and app name via an optional custom data parameter. ```cpp void RNCoreAppStart(RNCoreAppCallback launched, void *data) ``` -------------------------------- ### Navigate to Project Directory Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/getting-started.md After creating the project, change into the newly created project directory to continue with the setup. ```bat cd ``` -------------------------------- ### Install Dependencies Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/migration-guide.md Run this command after updating package.json to install or update project dependencies. ```bash npm install ``` ```bash yarn install ``` -------------------------------- ### Native module library codegenConfig example Source: https://context7.com/microsoft/react-native-windows-samples/llms.txt Example package.json configuration for a native module library specifying codegen settings for Windows. ```json "codegenConfig": { "name": "NativeModuleSampleSpec", "type": "all", "jsSrcsDir": "src", "includesGeneratedCode": true, "windows": { "namespace": "NativeModuleSampleCodegen", "generators": ["modulesWindows", "componentsWindows"], "outputDirectory": "windows/NativeModuleSample/codegen", "separateDataTypes": true } } ``` -------------------------------- ### Native module library development workflow Source: https://context7.com/microsoft/react-native-windows-samples/llms.txt Typical development workflow for a native module library, including installation, TypeScript compilation, code generation, and running the example app. ```bash yarn install yarn prepare # Compile TypeScript specs yarn codegen-windows # Generate C++ bindings yarn example windows # Run the example app targeting New Architecture ``` -------------------------------- ### Example react-native.config.js for MyModule Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/config.md This is an example of a `react-native.config.js` file for a module named 'MyModule', demonstrating how to specify Windows platform configurations, including the source directory, solution file, and project details. ```javascript module.exports = { dependency: { platforms: { windows: { sourceDir: 'windows', solutionFile: 'MyModule.sln', projects: [ { projectFile: 'MyModule\MyModule.vcxproj', directDependency: true, } ], }, }, }, }; ``` -------------------------------- ### Example Codegen Configuration Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/codegen-windows-cli.md This JSON object shows an example configuration for the `codegenConfig` in your `package.json` file. It specifies settings for both native modules and components, including Windows-specific options like namespace and output directory. ```json "codegenConfig": { "name": "NativeModuleSampleSpec", "type": "all", "jsSrcsDir": "src", "includesGeneratedCode": true, "windows": { "namespace": "NativeModuleSampleCodegen", "generators": [ "modulesWindows", "componentsWindows" ], "outputDirectory": "windows/NativeModuleSample/codegen", "separateDataTypes": true } }, ``` -------------------------------- ### Example react-native.config.js for Project Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/config.md An example of a manual override file for project configuration. This file allows developers to specify Windows-specific settings when `react-native config` cannot determine them heuristically. ```javascript module.exports = { project: { windows: { sourceDir: 'windows', solutionFile: 'MyApp.sln', project: { projectFile: 'MyApp\/MyApp.vcxproj', }, }, }, }; ``` -------------------------------- ### Build and Test React Native Windows Native Module Library Source: https://context7.com/microsoft/react-native-windows-samples/llms.txt Demonstrates authoring a TurboModule and Fabric Native Component in C++. Install dependencies, prepare specs, and run example apps for New (Fabric) or Old (Paper) Architectures. Use 'yarn codegen-windows' to re-generate C++ bindings. ```cmd cd react-native-windows-samples/samples/NativeModuleSample/cpp-lib :: Install dependencies and compile TypeScript specs yarn install yarn prepare :: Run the example app targeting New Architecture (Fabric) yarn example windows :: Run the example app targeting Old Architecture (Paper) yarn example-old windows :: Re-generate C++ bindings after spec changes: yarn codegen-windows :: Upgrade to latest RNW version: ..\..\..\.github\scripts\UpgradeSmokeTest.ps1 latest $True $True $True yarn prepare yarn codegen-windows ``` -------------------------------- ### Start CoreApp from Configuration JSON Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/blog/2022-07-29-coreapp.md This C API is similar to RNCoreAppStart but accepts a path to a JSON configuration file. The callback is optional as the configuration file often contains all necessary information. ```cpp void RNCoreAppStartFromConfigJson(wchar_t const *configJson, RNCoreAppCallback launched, void *data) ``` -------------------------------- ### Build Windows Project Source: https://github.com/microsoft/react-native-windows-samples/blob/main/samples-old/NativeModuleSample/csharp/README.md Command to verify the updated sample builds without deploying, launching, or starting the packager. ```bash npx @react-native-community/cli@latest run-windows --no-deploy --no-launch --no-packager --no-autolink --proj "NativeModuleSample\NativeModuleSample.csproj" ``` -------------------------------- ### Install Windows Extension Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/blog/2020-02-010-m4updates.md Run this command after adding the Windows extension plugin to your project. This command installs the necessary components for developing React Native applications on Windows. ```bash react-native windows ``` -------------------------------- ### RNCoreAppStartFromConfigJson Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/blog/2022-07-29-coreapp.md Starts a CoreApp using a JSON configuration file. It is similar to RNCoreAppStart but takes a path to a JSON file for configuration, making the callback optional. ```APIDOC ## RNCoreAppStartFromConfigJson ### Description This API is similar to `RNCoreAppStart` but it takes a path to a JSON configuration file. The callback is optional in this case, since more often than not, the configuration file will have all the necessary information. ### Signature ```cpp void RNCoreAppStartFromConfigJson(wchar_t const *configJson, RNCoreAppCallback launched, void *data) ``` ### Parameters #### Path Parameters - **configJson** (`wchar_t const *`): A wide character string representing the path to the JSON configuration file. #### Callback Parameters - **launched** (`RNCoreAppCallback`): An optional function pointer to a callback that is invoked when the app launches. This callback receives an `RNCoreApp` structure and the `data` pointer. - **data** (`void *`): Optional custom data to be passed to the `launched` callback. ``` -------------------------------- ### Install App Center CLI Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/blog/2021-05-17-codepush.md Install the App Center command-line interface globally using npm. This tool is required for pushing bundle updates to App Center. ```powershell npm install -g appcenter-cli ``` -------------------------------- ### RNCoreAppStart Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/blog/2022-07-29-coreapp.md Starts a CoreApp and calls back upon launch with optional custom data. The callback allows customization of parameters like bundle name and app name. ```APIDOC ## RNCoreAppStart ### Description Starts a `CoreApp`, and upon launch, it will call your app back and pass some optional custom data to it as a parameter. The callback enables you to customize a number of parameters, like your bundle name, app name, etc. ### Signature ```cpp void RNCoreAppStart(RNCoreAppCallback launched, void *data) ``` ### Parameters #### Callback Parameters - **launched** (`RNCoreAppCallback`): A function pointer to a callback that is invoked when the app launches. This callback receives an `RNCoreApp` structure and the `data` pointer. - **data** (`void *`): Optional custom data to be passed to the `launched` callback. ``` -------------------------------- ### Run the React Native Windows Application Source: https://github.com/microsoft/react-native-windows-samples/blob/main/samples-old/CalculatorCoreAppNuGet/README.md Execute this command after installing dependencies to build, deploy, and launch the application along with the React Native Server and Debugger. ```cmd npx react-native run-windows ``` -------------------------------- ### StartAnimation Method Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/native-api/IActivityVisual-api-windows.md Starts the animation for the visual element. ```APIDOC ## StartAnimation ### Description Starts the animation for the visual element. ### Signature void **`StartAnimation`**() ### Parameters None. ``` -------------------------------- ### Configure Header Links in siteConfig.js Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/README.md Example of how to add links to the site's top navigation bar, including documentation, custom pages, and external links. ```javascript { headerLinks: [ ... /* you can add docs */ { doc: 'my-examples', label: 'Examples' }, /* you can add custom pages */ { page: 'help', label: 'Help' }, /* you can add external links */ { href: 'https://github.com/facebook/docusaurus', label: 'GitHub' }, ... ], ... ``` -------------------------------- ### Configure GitHub Actions for Windows CI Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/setup-ci.md Basic YAML configuration for a GitHub Actions workflow to build and test a React Native Windows app on a Windows 2022 runner. Includes checkout, Node.js setup, MSBuild installation, and dependency installation. ```yaml name: Windows CI on: [pull_request] jobs: run-windows-tests: name: Build & run tests runs-on: windows-2022 steps: - uses: actions/checkout@v2 name: Checkout Code - name: Setup Node.js uses: actions/setup-node@v1 with: node-version: '^18' - name: Setup MSBuild uses: microsoft/setup-msbuild@v2 - name: Install node modules run: yarn --frozen-lockfile ``` -------------------------------- ### Initialize CodePush with Update Prompt Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/blog/2021-05-17-codepush.md Configure CodePush to prompt the user before downloading and installing updates. This provides user control over the update process, unless the update is mandatory. ```javascript import codePush from "react-native-code-push"; let App: () => React$Node = () => { //your app component } App = codePush({ updateDialog: true, installMode: codePush.InstallMode.IMMEDIATE })(App); export default App; ``` -------------------------------- ### Navigate to Samples Folder Source: https://github.com/microsoft/react-native-windows-samples/blob/main/samples/Calculator/fabric/README.md Change directory to the parent 'samples' folder as the first step in upgrading the sample. ```cmd cd .. ``` -------------------------------- ### Run TodosFeed as Standalone App Source: https://github.com/microsoft/react-native-windows-samples/blob/main/samples-old/TodosFeed/README.md Use this command to build, deploy, and launch the TodosFeed project as a standalone Windows application. It also starts the Metro bundler and dev tools. ```powershell react-native run-windows ``` -------------------------------- ### AutolinkedNativeModules.g.cpp Example Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/native-platform-using.md This C++ file defines a function to register native package providers. It includes necessary headers and appends package providers from linked libraries, enabling their native modules and components to be used at runtime. ```cpp // AutolinkedNativeModules.g.cpp contents generated by "npx @react-native-community/cli autolink-windows" // clang-format off #include "pch.h" #include "AutolinkedNativeModules.g.h" // Includes from testlib #include namespace winrt::Microsoft::ReactNative { void RegisterAutolinkedNativeModulePackages(winrt::Windows::Foundation::Collections::IVector const& packageProviders) { // IReactPackageProviders from testlib packageProviders.Append(winrt::testlib::ReactPackageProvider()); } } ``` -------------------------------- ### Verify Updated Sample Build Source: https://github.com/microsoft/react-native-windows-samples/blob/main/samples-old/NativeModuleSample/cppwinrt/README.md Run this command to verify that the sample builds correctly after an upgrade. It bypasses deployment and launching to focus solely on the build process. ```cmd npx @react-native-community/cli@latest run-windows --no-deploy --no-launch --no-packager --no-autolink --proj "NativeModuleSample\NativeModuleSample.vcxproj" ``` -------------------------------- ### Navigate to Samples Folder Source: https://github.com/microsoft/react-native-windows-samples/blob/main/samples/Calculator/cppwinrt/README.md Navigate to the parent directory of the current folder. ```cmd cd .. ``` -------------------------------- ### Markdown Frontmatter Example Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/README.md Example of frontmatter for a markdown document in Docusaurus. This includes the document ID and title. ```markdown --- id: page-needs-edit title: This Doc Needs To Be Edited --- Edit me... ``` -------------------------------- ### Initialize Method Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/native-api/CompositionHwndHost-api-windows.md Initializes the CompositionHwndHost with a given HWND. ```APIDOC ## Initialize(uint64_t hwnd) ### Description Initializes the `CompositionHwndHost` with the specified window handle (HWND). ### Method `void Initialize(uint64_t hwnd)` ### Parameters #### Path Parameters - **hwnd** (uint64_t) - Required - The handle to the window to host. ``` -------------------------------- ### Initialize New Windows Project with init-windows Source: https://context7.com/microsoft/react-native-windows-samples/llms.txt Scaffolds native Windows project files. Use `--overwrite` to re-initialize with custom options. Available templates include `cpp-app` and `cpp-lib`. ```bat npx --yes @react-native-community/cli@latest init --version "^0.82.0" cd MyApp yarn add react-native-windows@^0.82.0 npx react-native init-windows --overwrite npx react-native init-windows --list npx react-native init-windows --template cpp-app --name MyApp --namespace MyCompany.MyApp --overwrite # Resulting entry in package.json: # "react-native-windows": { # "init-windows": { # "name": "MyApp", # "namespace": "MyCompany.MyApp", # "template": "cpp-app" # } # } ``` -------------------------------- ### UIDispatcherProperty Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/native-api/ReactDispatcherHelper-api-windows.md Gets the name of the UIDispatcher property for the IReactPropertyBag. Generally you can use IReactContext.UIDispatcher to get the value of this property for a specific React instance. ```APIDOC ## UIDispatcherProperty ### Description Gets name of the `UIDispatcher` property for the [`IReactPropertyBag`](IReactPropertyBag). Generally you can use [`IReactContext.UIDispatcher`](IReactContext#uidispatcher) to get the value of this property for a specific React instance. ### Type `static readonly IReactPropertyName` ``` -------------------------------- ### Initialize New React Native App Source: https://github.com/microsoft/react-native-windows-samples/blob/main/samples/Calculator/fabric/README.md Create a new React Native project, specifying the desired version for the upgrade. ```cmd npx --yes @react-native-community/cli@latest init CalculatorFabric --template @react-native-community/template@latest --skip-git-init ``` -------------------------------- ### JSDispatcherProperty Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/native-api/ReactDispatcherHelper-api-windows.md Gets the name of the JSDispatcher property for the IReactPropertyBag. Generally you can use IReactContext.JSDispatcher to get the value of this property for a specific React instance. ```APIDOC ## JSDispatcherProperty ### Description Gets name of the `JSDispatcher` property for the [`IReactPropertyBag`](IReactPropertyBag). Generally you can use [`IReactContext.CallInvoker`](IReactContext#callinvoker) instead. ### Type `static readonly IReactPropertyName` ``` -------------------------------- ### Install React Native CodePush SDK Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/blog/2021-05-17-codepush.md Install the CodePush SDK using Yarn. This command should be run from the root of your React Native project. ```powershell yarn add react-native-code-push ``` -------------------------------- ### Reinitialize Windows Project with New Template Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/migration-guide.md Initialize the Windows project using the 'cpp-app' template to enable the new Fabric architecture. ```bash npx react-native init-windows --template cpp-app ``` -------------------------------- ### Initialize Windows with Old Architecture Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/new-architecture.md Use this command to set up a new React Native Windows project with the Old Architecture. This template uses UWP XAML for host components. ```bat yarn react-native init-windows --template old/uwp-cpp-app ``` -------------------------------- ### Run React Native Windows Calculator Sample Source: https://context7.com/microsoft/react-native-windows-samples/llms.txt Clone the repository and install dependencies to run the Calculator sample app. Use 'npx @react-native-community/cli@latest run-windows' to build and launch the app. Supports C++, C#, and Fabric (New Architecture) variants. ```cmd :: Clone the repository git clone https://github.com/microsoft/react-native-windows-samples.git cd react-native-windows-samples/samples/Calculator/cppwinrt :: Install dependencies yarn install :: Run the app (builds the VS solution, starts Metro, launches the app) npx @react-native-community/cli@latest run-windows :: To run the C# variant instead: cd ../csharp yarn install npx @react-native-community/cli@latest run-windows :: To run the Fabric (New Architecture) variant: cd ../fabric yarn install npx @react-native-community/cli@latest run-windows ``` -------------------------------- ### Install React Native Windows Dependencies Script Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/rnw-dependencies.md Run this command in an elevated PowerShell window to automatically install or check for necessary development dependencies for React Native Windows. ```powershell Set-ExecutionPolicy Unrestricted -Scope Process -Force; iex (New-Object System.Net.WebClient).DownloadString('https://aka.ms/rnw-vs2022-deps.ps1'); ``` -------------------------------- ### Initialize Windows with New Architecture Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/new-architecture.md Use this command to set up a new React Native Windows project with the New Architecture. This template utilizes the Windows App SDK's Visual Layer for host components. ```bat yarn react-native init-windows --template cpp-app ``` -------------------------------- ### Start Win32 Process in Separate Thread Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/blog/2021-08-05-win32component.md Starts the main process logic in a separate thread and uses AutoResetEvent to keep the main thread alive until the App Service connection is closed. ```csharp static AutoResetEvent appServiceExit; static AppServiceConnection connection = null; static void Main(string[] args) { appServiceExit = new AutoResetEvent(false); Thread appServiceThread = new Thread(new ThreadStart(ThreadProc)); appServiceThread.Start(); appServiceExit.WaitOne(); } ``` -------------------------------- ### Install Node.js LTS using WinGet Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/rnw-dependencies.md Use WinGet to install the Long-Term Support (LTS) version of Node.js, which is recommended for React Native development. Ensure you are running this command from an elevated Command Prompt. ```bat winget install OpenJS.NodeJS.LTS --version 18.18.0 ``` -------------------------------- ### Initialize CodePush in C++ App.cpp Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/blog/2021-05-17-codepush.md Replace the existing `OnLaunched` implementation in `App.cpp` with this code to initialize CodePush. Ensure you replace `` with your actual deployment key. ```cpp void App::OnLaunched(activation::LaunchActivatedEventArgs const& e) { winrt::Microsoft::CodePush::ReactNative::CodePushConfig::SetHost(Host()); auto configMap{ winrt::single_threaded_map() }; configMap.Insert(L"appVersion", L"1.0.0"); configMap.Insert(L"deploymentKey", L""); winrt::Microsoft::CodePush::ReactNative::CodePushConfig::Init(configMap); Frame rootFrame{ nullptr }; auto content = Window::Current().Content(); if (content) { rootFrame = content.try_as(); } // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == nullptr) { // Create a Frame to act as the navigation context and associate it with // a SuspensionManager key rootFrame = Frame(); rootFrame.NavigationFailed({ this, &App::OnNavigationFailed }); if (e.PreviousExecutionState() == ApplicationExecutionState::Terminated) { // Restore the saved session state only when appropriate, scheduling the // final launch steps after the restore is complete } if (e.PrelaunchActivated() == false) { if (rootFrame.Content() == nullptr) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(xaml_typename(), box_value(e.Arguments())); } // Place the frame in the current Window Window::Current().Content(rootFrame); ``` -------------------------------- ### Launch Win32 Process on App Start Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/blog/2021-08-05-win32component.md Use the useEffect hook in functional components to asynchronously launch a full-trust Win32 process when the React Native application starts. This ensures the background process is running before the UI is fully interactive. ```javascript useEffect(() => { async function launchProcess() { await NativeModules.ReactNativeAppServiceModule.launchFullTrustProcess(); } launchProcess(); }, []); ``` -------------------------------- ### Get Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/native-api/IReactPropertyBag-api-windows.md Retrieves the value of a specified property from the property bag. ```APIDOC ## Get ### Description Gets value of the `name` property. It returns null if the property does not exist. ### Method Object ### Parameters #### Path Parameters - **name** (IReactPropertyName) - Required - The name of the property to retrieve. ``` -------------------------------- ### Build and Run Native Module Source: https://github.com/microsoft/react-native-windows-samples/blob/main/samples-old/NativeModuleSample/README.md Builds and runs the native module for Windows. Use the --no-deploy, --no-launch, --no-packager, and --no-autolink flags for specific build configurations. ```cmd npx @react-native-community/cli@latest run-windows --no-deploy --no-launch --no-packager --no-autolink --proj "NativeModuleSample\NativeModuleSample.vsproj" ``` -------------------------------- ### CompositionUIService.ComponentFromReactTag Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/native-api/CompositionUIService-api-windows.md Gets the ComponentView from a react tag. This is an experimental feature. ```APIDOC ## ComponentFromReactTag ### Description Gets the ComponentView from a react tag. ### Method `static` [`ComponentView`](ComponentView) **`ComponentFromReactTag`** ### Parameters * **context** (`IReactContext`) - The React context. * **reactTag** (int64_t) - The tag of the React component. ### Returns [`ComponentView`](ComponentView) - The ComponentView associated with the react tag. ``` -------------------------------- ### Initialize CodePush SDK in C++ Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/blog/2021-05-17-codepush.md Configure the CodePush SDK with the application version and deployment key. Ensure the current window is active. ```cpp #include "pch.h" #include "MainPage.h" #include "App.h" using namespace winrt; using namespace Windows::UI::Xaml; int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) { ::Sample::App::Start(L"App\n"); return 0; } void CodePushDemoAppCpp::App::OnLaunched(LaunchActivatedEventArgs const& e) { if (rootFrame.Content() == nullptr) { // Process information, and navigate to call the new page rootFrame.Navigate(xaml_typename(), box_value(e.Arguments())); } // Ensure the current window is active Window::Current().Activate(); } void CodePushDemoAppCpp::App::OnActivated(IActivatedEventArgs const& e) { if (e.Kind() == ActivationKind::Launch) { auto launchArgs = e.As(); if (rootFrame.Content() == nullptr) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(xaml_typename(), box_value(launchArgs.Arguments())); } // Ensure the current window is active Window::Current().Activate(); } else { if (e.PrelaunchActivated() == false) { if (rootFrame.Content() == nullptr) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(xaml_typename(), box_value(e.Arguments())); } // Ensure the current window is active Window::Current().Activate(); } } } ``` -------------------------------- ### Initialize Windows Project Source: https://github.com/microsoft/react-native-windows-samples/blob/main/samples-old/NativeModuleSample/csharp/README.md Command to re-initialize the Windows project using the React Native CLI with a specific template. ```bash npx @react-native-community/cli@latest init-windows --template old/uwp-cs-lib --overwrite ``` -------------------------------- ### GetArrayBufferSize Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/native-api/JsiRuntime-api-windows.md Gets the size of an ArrayBuffer in bytes. This function is marked as EXPERIMENTAL. ```APIDOC ## GetArrayBufferSize ### Description Gets the size of an ArrayBuffer in bytes. ### Parameters * **arrayBuffer** (`JsiObjectRef`) - A reference to the ArrayBuffer object. ### Returns `uint32_t` - The size of the ArrayBuffer in bytes. > **EXPERIMENTAL** ``` -------------------------------- ### CompositionUIService.GetCompositor Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/native-api/CompositionUIService-api-windows.md Gets the Compositor used by this ReactNative instance. This is an experimental feature. ```APIDOC ## GetCompositor ### Description Gets the Compositor used by this ReactNative instance. ### Method `static` [`Compositor`](https://learn.microsoft.com/windows/windows-app-sdk/api/winrt/Microsoft.UI.Composition.Compositor) **`GetCompositor`** ### Parameters * **properties** (`IReactPropertyBag`) - The properties bag to retrieve the Compositor from. ### Returns [`Compositor`](https://learn.microsoft.com/windows/windows-app-sdk/api/winrt/Microsoft.UI.Composition.Compositor) - The Compositor instance. ``` -------------------------------- ### GetArraySize Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/native-api/JsiRuntime-api-windows.md Gets the number of elements in a JavaScript array. This function is marked as EXPERIMENTAL. ```APIDOC ## GetArraySize ### Description Gets the number of elements in a JavaScript array. ### Parameters * **arr** (`JsiObjectRef`) - A reference to the JavaScript array. ### Returns `uint32_t` - The number of elements in the array. > **EXPERIMENTAL** ``` -------------------------------- ### JSDispatcherTaskStartingEventName Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/native-api/ReactDispatcherHelper-api-windows.md Gets the name of the JSDispatcherTaskStartingEventName property for the IReactNotificationService. This notification name is to be used with IReactNotificationService. ```APIDOC ## JSDispatcherTaskStartingEventName ### Description Gets the name of the `JSDispatcherTaskStartingEventName` property for the [`IReactNotificationService`](IReactNotificationService). This notification name is to be used with IReactNotificationService. ### Type `static readonly IReactPropertyName` ``` -------------------------------- ### JSDispatcherIdleWaitStartingEventName Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/native-api/ReactDispatcherHelper-api-windows.md Gets the name of the JSDispatcherIdleWaitStartingEventName property for the IReactNotificationService. This notification name is to be used with IReactNotificationService. ```APIDOC ## JSDispatcherIdleWaitStartingEventName ### Description Gets the name of the `JSDispatcherIdleWaitStartingEventName` property for the [`IReactNotificationService`](IReactNotificationService). This notification name is to be used with IReactNotificationService. ### Type `static readonly IReactPropertyName` ``` -------------------------------- ### Build and Launch Windows App with run-windows Source: https://context7.com/microsoft/react-native-windows-samples/llms.txt Builds the Visual Studio solution, deploys the app, and starts the Metro bundler. Autolinking runs automatically unless `--no-autolink` is specified. Supports custom MSBuild properties and release configurations. ```bat # Run the app (default: Debug, x64) npx react-native run-windows # Run on a specific architecture with release configuration npx react-native run-windows --arch x86 --release # Pass custom MSBuild properties (e.g., enable Hermes Inspector in release builds) npx react-native run-windows --msbuildprops EnableHermesInspectorInReleaseFlavor=true # Skip autolinking step (use if already autolinked via VS) npx react-native run-windows --no-autolink # VS Code launch.json equivalent for "Debug Windows" button (F5): # { # "version": "0.2.0", # "configurations": [ # { # "name": "Debug Windows", # "cwd": "${workspaceFolder}", # "type": "reactnative", # "request": "launch", # "platform": "windows" # } # ] # } ``` -------------------------------- ### JSDispatcherIdleWaitCompletedEventName Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/native-api/ReactDispatcherHelper-api-windows.md Gets the name of the JSDispatcherIdleWaitCompletedEventName property for the IReactNotificationService. This notification name is to be used with IReactNotificationService. ```APIDOC ## JSDispatcherIdleWaitCompletedEventName ### Description Gets the name of the `JSDispatcherIdleWaitCompletedEventName` property for the [`IReactNotificationService`](IReactNotificationService). This notification name is to be used with IReactNotificationService. ### Type `static readonly IReactPropertyName` ``` -------------------------------- ### Create New React Native App Source: https://github.com/microsoft/react-native-windows-samples/blob/main/samples/Calculator/cppwinrt/README.md Initialize a new React Native application with a specified version of the template. ```cmd npx @react-native-community/cli@latest init Calculator --template @react-native-community/template@latest --skip-git-init ``` -------------------------------- ### Launch Full Trust Process Method Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/blog/2021-08-05-win32component.md Use this method to launch a classic Win32 process from a UWP application using the `FullTrustProcessLauncher` API. Ensure the 'Windows Desktop Extension for UWP' is added as a reference. ```csharp [ReactMethod("launchFullTrustProcess")] public async Task LaunchFullTrustProcessAsync() { await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync(); } ``` -------------------------------- ### Invoke Method Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/native-api/EmitEventSetterDelegate-api-windows.md The Invoke method is used to get the arguments for an event emit on an EventEmitter. ```APIDOC ## Invoke void **`Invoke`**([`JSValueArgWriter`](JSValueArgWriter) argWriter) ### Description This method is part of the `EmitEventSetterDelegate` and is responsible for writing the arguments for an event emission using the provided `JSValueArgWriter`. ``` -------------------------------- ### Initialize React Native Windows Project Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/init-windows-cli.md Use this command to initialize a new React Native for Windows project from a given template. It can also be used to re-initialize an existing project. ```bat npx react-native init-windows ``` -------------------------------- ### Get React Version Source: https://github.com/microsoft/react-native-windows-samples/blob/main/samples-old/NativeModuleSample/csharp/README.md Command to check the required version of 'react' for the latest 'react-native-windows'. ```bash npm info react-native-windows@latest devDependencies.react ``` -------------------------------- ### PackageProviders Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/native-api/ReactInstanceSettings-api-windows.md Gets a list of IReactPackageProvider, allowing the addition of native modules and custom view managers. ```APIDOC ## PackageProviders `readonly` [`IVector`](https://docs.microsoft.com/uwp/api/Windows.Foundation.Collections.IVector-1)<[`IReactPackageProvider`](IReactPackageProvider)> `PackageProviders` Gets a list of [`IReactPackageProvider`](IReactPackageProvider). Add an implementation of [`IReactPackageProvider`](IReactPackageProvider) to this list to define additional native modules and custom view managers to be included in the React instance. Auto-linking automatically adds [`IReactPackageProvider`](IReactPackageProvider) to the application's [`PackageProviders`](#packageproviders). ``` -------------------------------- ### Initialize CodePush in C# App.xaml.cs Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/blog/2021-05-17-codepush.md Replace the existing `OnLaunched` implementation in `App.xaml.cs` with this code to initialize CodePush. Ensure you replace `` with your actual deployment key. ```csharp protected override void OnLaunched(LaunchActivatedEventArgs e) { Microsoft.CodePush.ReactNative.CodePushConfig.SetHost(Host); Dictionary configMap = new Dictionary(); configMap.Add("appVersion", "1.0.0"); configMap.Add("deploymentKey", ""); Microsoft.CodePush.ReactNative.CodePushConfig.Init(configMap); Frame rootFrame = null; var content = Window.Current.Content; if (content != null) { rootFrame = content as Frame; } if (rootFrame == null) { rootFrame = new Frame(); if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { } if (!e.PrelaunchActivated) { if (rootFrame.Content == null) { rootFrame.Navigate(typeof(MainPage), e.Arguments); } Window.Current.Content = rootFrame; Window.Current.Activate(); } } else { if (!e.PrelaunchActivated) { if (rootFrame.Content == null) { rootFrame.Navigate(typeof(MainPage), e.Arguments); } Window.Current.Activate(); } } } ``` -------------------------------- ### Run Versioning Command Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/README.md Execute the versioning command to create a new directory of versioned docs. This preserves existing documents and makes them available for the specified version. ```bash cd website yarn run version 0.XX ``` -------------------------------- ### Get React Native Version Source: https://github.com/microsoft/react-native-windows-samples/blob/main/samples-old/NativeModuleSample/csharp/README.md Command to check the required version of 'react-native' for the latest 'react-native-windows'. ```bash npm info react-native-windows@latest devDependencies.react-native ``` -------------------------------- ### Initialize React Native for Windows Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/native-platform-getting-started.md Initialize the React Native for Windows native code and projects using the `cpp-lib` template and overwrite existing files if necessary. ```bat npx react-native init-windows --template cpp-lib --overwrite ``` -------------------------------- ### Add React Native for Windows Dependencies Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/native-platform-getting-started.md Add `react-native-windows` as a development and peer dependency, then install all project dependencies. ```bat yarn add react-native-windows@^0.82.0 --dev yarn add react-native-windows@* --peer yarn install ``` -------------------------------- ### Initialize New React Native App Source: https://github.com/microsoft/react-native-windows-samples/blob/main/samples-old/CalculatorNuGet/README.md Creates a new React Native project named CalculatorNuGet, specifying a target version. ```cmd npx react-native init CalculatorNuGet --template "react-native@^0.72.0" ``` -------------------------------- ### Create New React Native Project Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/getting-started.md Use this command to initialize a new React Native project with a specific version of React Native. Ensure the CLI and RN version tags are correct for your documentation context. ```bat npx --yes @react-native-community/cli@latest init --version "^0.82.0" ``` -------------------------------- ### Run Windows Codegen Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/codegen-windows-cli.md Use this command to run the Windows-specific codegen for native modules. Ensure you have the React Native CLI installed. ```bash npx react-native codegen-windows ``` -------------------------------- ### IReactPropertyNamespace Interface Source: https://github.com/microsoft/react-native-windows-samples/blob/main/website/versioned_docs/version-0.82/native-api/IReactPropertyNamespace-api-windows.md This interface defines a namespace for property names within an IReactPropertyBag. It provides a way to get the string representation of the namespace. ```APIDOC ## Interface: IReactPropertyNamespace ### Description A namespace for a [`IReactPropertyBag`](IReactPropertyBag) property name. Use [`ReactPropertyBagHelper.GetNamespace`](ReactPropertyBagHelper#getnamespace) to get atomic property namespace for a string. ### Properties #### NamespaceName - **Type**: `readonly string` - **Description**: Gets String representation of the [`IReactPropertyNamespace`](IReactPropertyNamespace). ```