File tree Expand file tree Collapse file tree 3 files changed +48
-0
lines changed
packages/create-react-native-library/templates/native-view-library-mixed/src Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ import type { TurboModule } from 'react-native' ;
2
+ import { TurboModuleRegistry } from 'react-native' ;
3
+
4
+ export interface Spec extends TurboModule {
5
+ multiply ( a : number , b : number ) : Promise < number > ;
6
+ }
7
+
8
+ export default TurboModuleRegistry . getEnforcing < Spec > ( '<%- project.name -%>' ) ;
Original file line number Diff line number Diff line change
1
+ import { NativeModules , Platform } from 'react-native' ;
2
+
3
+ const LINKING_ERROR =
4
+ `The package '<%- project.slug -%>' doesn't seem to be linked. Make sure: \n\n` +
5
+ Platform . select ( { ios : "- You have run 'pod install'\n" , default : '' } ) +
6
+ '- You rebuilt the app after installing the package\n' +
7
+ '- You are not using Expo Go\n' ;
8
+
9
+ // @ts -expect-error
10
+ const isTurboModuleEnabled = global . __turboModuleProxy != null ;
11
+
12
+ const < % - project . name - % > Module = isTurboModuleEnabled
13
+ ? require ( './Native<%- project.name -%>' ) . default
14
+ : NativeModules . < % - project . name - % > ;
15
+
16
+ const < % - project . name - % > = < % - project . name - % > Module
17
+ ? < % - project . name - % > Module
18
+ : new Proxy (
19
+ { } ,
20
+ {
21
+ get ( ) {
22
+ throw new Error ( LINKING_ERROR ) ;
23
+ } ,
24
+ }
25
+ ) ;
26
+
27
+ export function multiply ( a : number , b : number ) : Promise < number > {
28
+ return < % - project . name - % > . multiply ( a , b ) ;
29
+ }
30
+
31
+ export { default as < % - project . name - % > View } from './<%- project.name -%>NativeComponent' ;
32
+ export * from './<%- project.name -%>NativeComponent' ;
Original file line number Diff line number Diff line change
1
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent' ;
2
+ import type { ViewProps } from 'react-native' ;
3
+
4
+ interface NativeProps extends ViewProps {
5
+ color ?: string ;
6
+ }
7
+
8
+ export default codegenNativeComponent < NativeProps > ( '<%- project.name -%>View' ) ;
You can’t perform that action at this time.
0 commit comments