@@ -10,12 +10,13 @@ import AsyncStorage from "@react-native-async-storage/async-storage";
1010import React , { useCallback , useState } from "react" ;
1111import {
1212 Button ,
13- NativeModules ,
1413 StyleSheet ,
1514 Text ,
1615 TextInput ,
16+ TurboModuleRegistry ,
1717 View ,
1818} from "react-native" ;
19+ import type { AsyncStorageTestSupport } from "./types" ;
1920
2021type Personalia = {
2122 age : string ;
@@ -102,6 +103,9 @@ function Merge(): JSX.Element {
102103
103104 const { trait1, trait2 } = traits ;
104105
106+ const AsyncStorageTestSupport =
107+ TurboModuleRegistry . get < AsyncStorageTestSupport > ( "AsyncStorageTestSupport" ) ;
108+
105109 return (
106110 < View >
107111 < View >
@@ -174,26 +178,14 @@ function Merge(): JSX.Element {
174178 < Button
175179 testID = "setDelegate_button"
176180 title = "Set native delegate"
177- disabled = {
178- ! NativeModules [ "AsyncStorageTestSupport" ] ||
179- ! NativeModules [ "AsyncStorageTestSupport" ] . test_setDelegate
180- }
181- onPress = { ( ) =>
182- NativeModules [ "AsyncStorageTestSupport" ] . test_setDelegate ( ( ) => { } )
183- }
181+ disabled = { ! AsyncStorageTestSupport ?. test_setDelegate }
182+ onPress = { ( ) => AsyncStorageTestSupport ?. test_setDelegate ( ( ) => { } ) }
184183 />
185184 < Button
186185 testID = "unsetDelegate_button"
187186 title = "Unset native delegate"
188- disabled = {
189- ! NativeModules [ "AsyncStorageTestSupport" ] ||
190- ! NativeModules [ "AsyncStorageTestSupport" ] . test_unsetDelegate
191- }
192- onPress = { ( ) =>
193- NativeModules [ "AsyncStorageTestSupport" ] . test_unsetDelegate (
194- ( ) => { }
195- )
196- }
187+ disabled = { ! AsyncStorageTestSupport ?. test_unsetDelegate }
188+ onPress = { ( ) => AsyncStorageTestSupport ?. test_unsetDelegate ( ( ) => { } ) }
197189 />
198190 </ View >
199191
0 commit comments