Skip to content

Commit

Permalink
fix: use expo go
Browse files Browse the repository at this point in the history
  • Loading branch information
linonetwo committed Mar 15, 2024
1 parent e43b833 commit 96f442b
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/services/NativeService/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
/* eslint-disable @typescript-eslint/strict-boolean-expressions */
/** If you get error on development:
* ```
* Error: Cannot find native module 'ExpoShareIntentModule', js engine: hermes
* Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes
* ```
*
* Comment out this import will work.
*
* Also comment out all code inside `useRegisterReceivingShareIntent`.
*/
import { useShareIntent } from 'expo-share-intent';
import type { useShareIntent as IUseShareIntent } from 'expo-share-intent';
import { useEffect } from 'react';
import { useRegisterProxy } from 'react-native-postmessage-cat';
import { nativeService } from '.';
Expand All @@ -32,8 +20,23 @@ export function useRequestNativePermissions() {
}

export function useRegisterReceivingShareIntent() {
/** UnComment `return;` to fix `Error: Cannot find native module 'ExpoShareIntentModule', js engine: hermes` */
// return;
/** If you get error on development:
* ```
* Error: Cannot find native module 'ExpoShareIntentModule', js engine: hermes
* Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes
* ```
*
* Comment out this import will work.
*
* Also comment out all code inside `useRegisterReceivingShareIntent`.
*/
if (process.env.NODE_ENV === 'development') {
return;
}
const { useShareIntent } = require('expo-share-intent') as { useShareIntent: typeof IUseShareIntent };
/* eslint-disable react-hooks/rules-of-hooks */
const { hasShareIntent, shareIntent, resetShareIntent, error } = useShareIntent({
debug: true,
});
Expand All @@ -44,9 +47,6 @@ export function useRegisterReceivingShareIntent() {
`Failed to get ShareIntent, This is normal if you are using Expo Go for dev. To debug sharing feature, create a dev build "pnpm start:devClient" instead. ${error}`,
);
}
// if (process.env.NODE_ENV === 'development') {
// return;
// }
void (async () => {
try {
if (hasShareIntent) {
Expand Down

0 comments on commit 96f442b

Please sign in to comment.