Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { NativeModules, Platform } from 'react-native';

const LINKING_ERROR =
`The package '<%- project.slug -%>' doesn't seem to be linked. Make sure: \n\n` +
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
'- You rebuilt the app after installing the package\n' +
'- You are not using Expo Go\n';

const <%- project.name -%> = NativeModules.<%- project.name %>
? NativeModules.<%- project.name %>
: new Proxy(
{},
{
get() {
throw new Error(LINKING_ERROR);
},
}
);

export function multiply(a: number, b: number): Promise<number> {
return <%- project.name -%>.multiply(a, b);
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,2 @@
import { NativeModules, Platform } from 'react-native';
export * from './Native<%- project.name -%>';

const LINKING_ERROR =
`The package '<%- project.slug -%>' doesn't seem to be linked. Make sure: \n\n` +
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
'- You rebuilt the app after installing the package\n' +
'- You are not using Expo Go\n';

const <%- project.name -%> = NativeModules.<%- project.name %>
? NativeModules.<%- project.name %>
: new Proxy(
{},
{
get() {
throw new Error(LINKING_ERROR);
},
}
);

export function multiply(a: number, b: number): Promise<number> {
return <%- project.name -%>.multiply(a, b);
}
Original file line number Diff line number Diff line change
@@ -1,26 +1 @@
import {
requireNativeComponent,
UIManager,
Platform,
type ViewStyle,
} from 'react-native';

const LINKING_ERROR =
`The package '<%- project.slug -%>' doesn't seem to be linked. Make sure: \n\n` +
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
'- You rebuilt the app after installing the package\n' +
'- You are not using Expo Go\n';

type <%- project.name -%>Props = {
color: string;
style: ViewStyle;
};

const ComponentName = '<%- project.name -%>View';

export const <%- project.name -%>View =
UIManager.getViewManagerConfig(ComponentName) != null
? requireNativeComponent<<%- project.name -%>Props>(ComponentName)
: () => {
throw new Error(LINKING_ERROR);
};
export * from './<%- project.name -%>View';
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {
requireNativeComponent,
UIManager,
Platform,
ViewStyle,
} from 'react-native';

const LINKING_ERROR =
`The package '<%- project.slug -%>' doesn't seem to be linked. Make sure: \n\n` +
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
'- You rebuilt the app after installing the package\n' +
'- You are not using Expo Go\n';

type <%- project.name -%>Props = {
color: string;
style: ViewStyle;
};

const ComponentName = '<%- project.name -%>View';

export const <%- project.name -%>View = UIManager.getViewManagerConfig(ComponentName) != null
? requireNativeComponent<<%- project.name -%>Props>(ComponentName)
: () => {
throw new Error(LINKING_ERROR);
};