Skip to content

Conversation

@jonthysell
Copy link
Contributor

@jonthysell jonthysell commented Oct 23, 2024

This PR backports #13983 to 0.76.

Description

This PR simplifies and scopes down the API for ReactNativeAppBuilder and ReactNativeWin32App.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Why

ReactNativeAppBuilder's API surface made it too easy to call incorrectly and not realize it.

Resolves #13946

What

There are a variety of changes to the API surface:

  • ReactInstanceSettingsBuilder deleted: not only are there are simply too many APIs that would need to be exposed to be useful, the very act of creating and replacing the app's ReactNativeHost's ReactInstanceSettings with a new one is what caused the bug in When Using New App Template (with ReactNativeAppBuilder) In-App Defined Native Modules Are Not Automatically Registered #13946 in the first place
  • ReactNativeAppBuilder now only exposes APIs to specify the intial, non-ReactNative, WinAppSDK types, (i.e. DispatcherQueueController, Compositor, and AppWindow), objects the app developer may already have created for their existing app, and otherwise is only responsible for building a ReactNativeWin32App with those types properly pre-made
  • ReactNativeWin32App::Start() is now more responsible for the stitching together all of the relevant types to make a working Win32 fabric app
  • All WinRT APIs without an immediate use-case have been commented out until we are sure they are necessary and that it is safe to expose them
  • The template has been updated to follow the pattern of:
    • Use ReactNativeAppBuilder to get a ReactNativeWin32 app with the base WinAppSDK types ready
    • Get and modify the types as necessary from the created app object (like the ReactInstanceSettings and the AppWindow)
    • Call app.Start()

Screenshots

N/A

Testing

Verified new apps and example apps in libraryes build and run properly.

Changelog

Should this change be included in the release notes: yes

Cleanup ReactNativeAppBuilder and ReactNativeWin32App

Microsoft Reviewers: Open in CodeFlow

This PR backports microsoft#13983 to 0.76.

## Description

This PR simplifies and scopes down the API for `ReactNativeAppBuilder` and `ReactNativeWin32App`.

### Type of Change
- Bug fix (non-breaking change which fixes an issue)

### Why
`ReactNativeAppBuilder`'s API surface made it too easy to call incorrectly and not realize it.

Resolves microsoft#13946

### What

There are a variety of changes to the API surface:
* `ReactInstanceSettingsBuilder` deleted: not only are there are simply too many APIs that would need to be exposed to be useful, the very act of creating and replacing the app's `ReactNativeHost`'s `ReactInstanceSettings` with a new one is what caused the bug in microsoft#13946 in the first place
* `ReactNativeAppBuilder` now only exposes APIs to specify the intial, non-ReactNative, WinAppSDK types, (i.e. `DispatcherQueueController`, `Compositor`, and `AppWindow`), objects the app developer may already have created for their existing app, and otherwise is only responsible for building a `ReactNativeWin32App` with those types properly pre-made
* `ReactNativeWin32App::Start()` is now more responsible for the stitching together all of the relevant types to make a working Win32 fabric app
* All WinRT APIs without an immediate use-case have been commented out until we are sure they are necessary and that it is safe to expose them
* The template has been updated to follow the pattern of:
    * Use `ReactNativeAppBuilder` to get a `ReactNativeWin32` app with the base WinAppSDK types ready
    * Get and modify the types as necessary from the created app object (like the `ReactInstanceSettings` and the `AppWindow`)
    * Call `app.Start()`

## Screenshots
N/A

## Testing
Verified new apps and example apps in libraryes build and run properly.

## Changelog
Should this change be included in the release notes: _yes_

Cleanup ReactNativeAppBuilder and ReactNativeWin32App
@jonthysell jonthysell requested review from a team as code owners October 23, 2024 19:24
@jonthysell jonthysell merged commit 591db2c into microsoft:0.76-stable Oct 24, 2024
@jonthysell jonthysell deleted the appbuildercleanup76 branch October 24, 2024 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants