react-native-windows icon indicating copy to clipboard operation
react-native-windows copied to clipboard

Cleanup ReactNativeAppBuilder and ReactNativeWin32App

Open jonthysell opened this issue 1 year ago • 0 comments

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 #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

jonthysell avatar Oct 16 '24 01:10 jonthysell