From d5b8afee66e8901c2e694db40f6276db87a20c7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwas=CC=81niewski?= Date: Thu, 22 Sep 2022 14:59:10 +0200 Subject: [PATCH 1/2] fix: remove isTurboModuleEnabled check --- .../backward-compatibility-turbomodules.md | 34 ++----------------- .../backward-compatibility-turbomodules.md | 34 ++----------------- 2 files changed, 6 insertions(+), 62 deletions(-) diff --git a/docs/the-new-architecture/backward-compatibility-turbomodules.md b/docs/the-new-architecture/backward-compatibility-turbomodules.md index fbc2e89a063..f1235c6395f 100644 --- a/docs/the-new-architecture/backward-compatibility-turbomodules.md +++ b/docs/the-new-architecture/backward-compatibility-turbomodules.md @@ -347,7 +347,7 @@ For a Turbo Native Module, the source of truth is the `Native.js` (or import MyModule from 'your-module/src/index'; ``` -The **goal** is to conditionally `export` the proper object from the `index` file , given the architecture chosen by the user. We can achieve this with a code that looks like this: +Since `TurboModuleRegistry.get` taps into the old `NativeModules` API under the hood, we need to re-export our module, to avoid registering it multiple times. ').default : - NativeModules.; - -export default myModule; +export default require('./Native').default; ``` ```ts -const isTurboModuleEnabled = global.__turboModuleProxy != null; - -const myModule = isTurboModuleEnabled - ? require('./Native').default - : require('./').default; - -export default myModule; +export default require('./Native').default; ``` - -:::note -If you are using TypeScript and you want to follow the example, ensure to `export` the `NativeModule` in a separate `ts` file called `.ts`. -::: - -Whether you are using Flow or TypeScript for your specs, we understand which architecture is running by checking whether the `global.__turboModuleProxy` object has been set or not. - -:::caution -The `global.__turboModuleProxy` API may change in the future for a function that encapsulates this check. -::: - -- If that object is `null`, the app has not enabled the Turbo Native Module feature. It's running on the Old Architecture, and the fallback is to use the default [`Legacy Native Module` implementation](../native-modules-intro). -- If that object is set, the app is running with the Turbo Native Modules enabled, and it should use the `Native` spec to access the Turbo Native Module. diff --git a/website/versioned_docs/version-0.70/the-new-architecture/backward-compatibility-turbomodules.md b/website/versioned_docs/version-0.70/the-new-architecture/backward-compatibility-turbomodules.md index 032e2328de4..d6a94b7ef69 100644 --- a/website/versioned_docs/version-0.70/the-new-architecture/backward-compatibility-turbomodules.md +++ b/website/versioned_docs/version-0.70/the-new-architecture/backward-compatibility-turbomodules.md @@ -332,7 +332,7 @@ For a Turbo Native Module, the source of truth is the `Native.js` (or import MyModule from 'your-module/src/index'; ``` -The **goal** is to conditionally `export` from the `index` file the proper object, given the architecture chosen by the user. We can achieve this with a code that looks like this: +Since `TurboModuleRegistry.get` taps into the old `NativeModules` API under the hood, we need to re-export our module, to avoid registering it multiple times. ').default : - NativeModules.; - -export default myModule; +export default require('./Native').default; ``` ```ts -const isTurboModuleEnabled = global.__turboModuleProxy != null; - -const myModule = isTurboModuleEnabled - ? require('./Native').default - : require('./').default; - -export default myModule; +export default require('./Native').default; ``` - -:::note -If you are using TypeScript and you want to follow the example, make sure to `export` the `NativeModule` in a separate `ts` file called `.ts`. -::: - -Whether you are using Flow or TypeScript for your specs, we understand which architecture is running by checking whether the `global.__turboModuleProxy` object has been set or not. - -:::caution -The `global.__turboModuleProxy` API may change in the future for a function that encapsulate this check. -::: - -- If that object is `null`, the app has not enabled the Turbo Native Module feature. It's running on the Old Architecture, and the fallback is to use the default [`Legacy Native Module` implementation](../native-modules-intro). -- If that object is set, the app is running with the Turbo Native Modules enabled, and it should use the `Native` spec to access the Turbo Native Module. From 9766ae5dd9d2bfa4501f4b450bd92e4fcc84f79d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwa=C5=9Bniewski?= Date: Thu, 22 Sep 2022 15:34:11 +0200 Subject: [PATCH 2/2] fix: remove unnecessary back ticks Co-authored-by: Riccardo --- .../the-new-architecture/backward-compatibility-turbomodules.md | 2 +- .../the-new-architecture/backward-compatibility-turbomodules.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/the-new-architecture/backward-compatibility-turbomodules.md b/docs/the-new-architecture/backward-compatibility-turbomodules.md index f1235c6395f..70758ca9627 100644 --- a/docs/the-new-architecture/backward-compatibility-turbomodules.md +++ b/docs/the-new-architecture/backward-compatibility-turbomodules.md @@ -347,7 +347,7 @@ For a Turbo Native Module, the source of truth is the `Native.js` (or import MyModule from 'your-module/src/index'; ``` -Since `TurboModuleRegistry.get` taps into the old `NativeModules` API under the hood, we need to re-export our module, to avoid registering it multiple times. +Since `TurboModuleRegistry.get` taps into the old Native Modules API under the hood, we need to re-export our module, to avoid registering it multiple times. .js` (or import MyModule from 'your-module/src/index'; ``` -Since `TurboModuleRegistry.get` taps into the old `NativeModules` API under the hood, we need to re-export our module, to avoid registering it multiple times. +Since `TurboModuleRegistry.get` taps into the old Native Modules API under the hood, we need to re-export our module, to avoid registering it multiple times.