From 94cf6b49453a337f18d15c428c7bc2573f483bc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Daipr=C3=A9?= Date: Thu, 7 Aug 2025 08:24:02 -0300 Subject: [PATCH 1/4] fix CodegenTypes EventEmitter --- .../native-modules-custom-events.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/the-new-architecture/native-modules-custom-events.md b/docs/the-new-architecture/native-modules-custom-events.md index 99c0875fbe7..b2c8a79624f 100644 --- a/docs/the-new-architecture/native-modules-custom-events.md +++ b/docs/the-new-architecture/native-modules-custom-events.md @@ -23,9 +23,8 @@ The first step would be to update the specs of the `NativeLocalStorage` specs to Open the `NativeLocalStorage.ts` file and update it as it follows: ```diff title="NativeLocalStorage.ts" -import type {TurboModule} from 'react-native'; +import type {TurboModule, CodegenTypes} from 'react-native'; import {TurboModuleRegistry} from 'react-native'; -+import type {EventEmitter} from 'react-native/Libraries/Types/CodegenTypes'; +export type KeyValuePair = { + key: string, @@ -38,7 +37,7 @@ export interface Spec extends TurboModule { removeItem(key: string): void; clear(): void; -+ readonly onKeyAdded: EventEmitter; ++ readonly onKeyAdded: CodegenTypes.EventEmitter; } export default TurboModuleRegistry.getEnforcing( @@ -54,9 +53,8 @@ Open the `NativeLocalStorage.js` file and update it as it follows: ```diff title="NativeLocalStorage.js" // @flow -import type {TurboModule} from 'react-native'; +import type {TurboModule, CodegenTypes} from 'react-native'; import {TurboModule, TurboModuleRegistry} from 'react-native'; -+import type {EventEmitter} from 'react-native/Libraries/Types/CodegenTypes'; +export type KeyValuePair = { + key: string, @@ -68,7 +66,7 @@ export interface Spec extends TurboModule { getItem(key: string): ?string; removeItem(key: string): void; clear(): void; -+ onKeyAdded: EventEmitter ++ onKeyAdded: CodegenTypes.EventEmitter } export default (TurboModuleRegistry.get( 'NativeLocalStorage' From 877179408bfeb9266e75562eec0d6ef05c765f17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Daipr=C3=A9?= Date: Thu, 7 Aug 2025 08:37:18 -0300 Subject: [PATCH 2/4] fix versioned doc --- .../native-modules-custom-events.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/website/versioned_docs/version-0.80/the-new-architecture/native-modules-custom-events.md b/website/versioned_docs/version-0.80/the-new-architecture/native-modules-custom-events.md index 99c0875fbe7..aceae623519 100644 --- a/website/versioned_docs/version-0.80/the-new-architecture/native-modules-custom-events.md +++ b/website/versioned_docs/version-0.80/the-new-architecture/native-modules-custom-events.md @@ -23,9 +23,8 @@ The first step would be to update the specs of the `NativeLocalStorage` specs to Open the `NativeLocalStorage.ts` file and update it as it follows: ```diff title="NativeLocalStorage.ts" -import type {TurboModule} from 'react-native'; ++import type {TurboModule, CodegenTypes} from 'react-native'; import {TurboModuleRegistry} from 'react-native'; -+import type {EventEmitter} from 'react-native/Libraries/Types/CodegenTypes'; +export type KeyValuePair = { + key: string, @@ -38,7 +37,7 @@ export interface Spec extends TurboModule { removeItem(key: string): void; clear(): void; -+ readonly onKeyAdded: EventEmitter; ++ readonly onKeyAdded: CodegenTypes.EventEmitter; } export default TurboModuleRegistry.getEnforcing( @@ -54,9 +53,8 @@ Open the `NativeLocalStorage.js` file and update it as it follows: ```diff title="NativeLocalStorage.js" // @flow -import type {TurboModule} from 'react-native'; ++import type {TurboModule, CodegenTypes} from 'react-native'; import {TurboModule, TurboModuleRegistry} from 'react-native'; -+import type {EventEmitter} from 'react-native/Libraries/Types/CodegenTypes'; +export type KeyValuePair = { + key: string, @@ -68,7 +66,7 @@ export interface Spec extends TurboModule { getItem(key: string): ?string; removeItem(key: string): void; clear(): void; -+ onKeyAdded: EventEmitter ++ onKeyAdded: CodegenTypes.EventEmitter } export default (TurboModuleRegistry.get( 'NativeLocalStorage' @@ -78,7 +76,7 @@ export default (TurboModuleRegistry.get( -With the `import type` statement, you are importing the `EventEmitter` type that is required to then add the `onKeyAdded` property. +With the `import type` statement, you are importing the `CodegenTypes` from react-native, which includes the `EventEmitter` type. This allows you to define the `onKeyAdded` property using `CodegenTypes.EventEmitter`, specifying that the event will emit a payload of type `KeyValuePair`. When the event is emitted, you expect for it to receive a parameter of type `string`. From 359ccd23cdd6a4bb855fa52112a570b20fdbae16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Daipr=C3=A9?= Date: Thu, 7 Aug 2025 08:39:50 -0300 Subject: [PATCH 3/4] fix next docs --- docs/the-new-architecture/native-modules-custom-events.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/the-new-architecture/native-modules-custom-events.md b/docs/the-new-architecture/native-modules-custom-events.md index b2c8a79624f..490e021ccfe 100644 --- a/docs/the-new-architecture/native-modules-custom-events.md +++ b/docs/the-new-architecture/native-modules-custom-events.md @@ -23,7 +23,7 @@ The first step would be to update the specs of the `NativeLocalStorage` specs to Open the `NativeLocalStorage.ts` file and update it as it follows: ```diff title="NativeLocalStorage.ts" -import type {TurboModule, CodegenTypes} from 'react-native'; ++import type {TurboModule, CodegenTypes} from 'react-native'; import {TurboModuleRegistry} from 'react-native'; +export type KeyValuePair = { @@ -53,7 +53,7 @@ Open the `NativeLocalStorage.js` file and update it as it follows: ```diff title="NativeLocalStorage.js" // @flow -import type {TurboModule, CodegenTypes} from 'react-native'; ++import type {TurboModule, CodegenTypes} from 'react-native'; import {TurboModule, TurboModuleRegistry} from 'react-native'; +export type KeyValuePair = { @@ -76,7 +76,7 @@ export default (TurboModuleRegistry.get( -With the `import type` statement, you are importing the `EventEmitter` type that is required to then add the `onKeyAdded` property. +With the `import type` statement, you are importing the `CodegenTypes` from `react-native`, which includes the `EventEmitter` type. This allows you to define the `onKeyAdded` property using `CodegenTypes.EventEmitter`, specifying that the event will emit a payload of type `KeyValuePair`. When the event is emitted, you expect for it to receive a parameter of type `string`. From af53a262dc9fa947b506885a451be27a3d6aca64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Daipr=C3=A9?= Date: Thu, 7 Aug 2025 08:41:22 -0300 Subject: [PATCH 4/4] Update native-modules-custom-events.md --- .../the-new-architecture/native-modules-custom-events.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/versioned_docs/version-0.80/the-new-architecture/native-modules-custom-events.md b/website/versioned_docs/version-0.80/the-new-architecture/native-modules-custom-events.md index aceae623519..490e021ccfe 100644 --- a/website/versioned_docs/version-0.80/the-new-architecture/native-modules-custom-events.md +++ b/website/versioned_docs/version-0.80/the-new-architecture/native-modules-custom-events.md @@ -76,7 +76,7 @@ export default (TurboModuleRegistry.get( -With the `import type` statement, you are importing the `CodegenTypes` from react-native, which includes the `EventEmitter` type. This allows you to define the `onKeyAdded` property using `CodegenTypes.EventEmitter`, specifying that the event will emit a payload of type `KeyValuePair`. +With the `import type` statement, you are importing the `CodegenTypes` from `react-native`, which includes the `EventEmitter` type. This allows you to define the `onKeyAdded` property using `CodegenTypes.EventEmitter`, specifying that the event will emit a payload of type `KeyValuePair`. When the event is emitted, you expect for it to receive a parameter of type `string`.