helium / helium/react-native-helium
Cannot read property 'SolanaProvider' of undefined
- Dominant language
- TypeScript
- Stars
- 15
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
TypeError: Cannot read property 'href' of undefined, js engine: hermes
ERROR TypeError: Cannot read property 'SolanaProvider' of undefined
This error is located at:
in App (created by RootApp)
in ReactNativeProfiler (created by RootApp)
in RCTView (created by View)
in View (created by __Sentry.TouchEventBoundary)
in __Sentry.TouchEventBoundary (created by RootApp)
in RootApp (created by Root)
in PersistGate (created by Root)
in Provider (created by Root)
in LanguageProvider (created by Root)
in RCTView (created by View)
in View (created by __Sentry.TouchEventBoundary)
in __Sentry.TouchEventBoundary (created by Root)
in Root (created by CodePushComponent)
in CodePushComponent
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
in SenseCAP(RootComponent), js engine: hermes
ERROR TypeError: Cannot read property 'href' of undefined, js engine: hermes
ERROR Error: Requiring module "node_modules/@helium/react-native-sdk/src/index.tsx", which threw an exception: TypeError: Cannot read property 'href' of undefined, js engine: hermes
I checked your source code and found that the module path is correct, so my VSCode did not show any errors. However, after Metro finished loading and I ran the app, the above error occurred.
I also checked the `wallet-app` code you provided and noticed that you are using Node 18. So, I upgraded to version 18, but the issue still persisted after running the app.
Then, I modified all the relevant dependencies in my `package.json` according to your example code. Below is my `package.json`:
```json
{
"name": "SenseCAP",
"version": "1.2.0",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"bundle-ios": "node node_modules/react-native/local-cli/cli.js bundle --entry-file index.js --platform ios --dev false --bundle-output ./ios/bundle/index.ios.jsbundle --assets-dest ./ios/bundle",
"bundle-android": "react-native bundle --platform android --entry-file index.js --bundle-output ./android/bundle/index.android.bundle --assets-dest ./android/bundle --dev false",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx && tsc",
"prettier": "prettier --write *.ts*",
"start": "react-native start",
"test": "jest",
"test-snap": "jest -u",
"icon": "yarn icon-label && yarn icon-gen && yarn icon-cleanup",
"icon-label": "app-icon label -i icon.png -o output.png --bottom 3.0.0",
"icon-gen": "app-icon generate -i output.png",
"icon-cleanup": "rm output.png",
"android-clean": "cd android && ./gradlew clean && cd ..",
"ios-clean": "rm -rf ios/Pods && rm -rf ios/build && rm -rf ios/Podfile.lock && sudo rm -rf ~/Library/Developer/Xcode/DerivedData && cd ios && pod cache clean --all && cd ..",
"pod-install": "cd ios && pod install && cd ..",
"clean-install": "watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && yarn cache clean && yarn install && yarn android-clean && yarn ios-clean && yarn pod-install",
"clean-start": "yarn start -- --reset-cache",
"postinstall": "patch-package",
"clean--ios-pod": "yarn ios-clean && yarn pod-install",
"bump-patch": "npx react-native bump-version --skip-semver-for android --skip-code-for all --type patch",
"bump-minor": "npx react-native bump-version --skip-semver-for android --skip-code-for all --type minor",
"prepare": "husky install",
"code-push": "./scripts/code-push.sh"
},
"dependencies": {
"@aws-amplify/pushnotification": "^4.3.12",
"@azure/core-asynciterator-polyfill": "^1.0.2",
"@coral-xyz/anchor": "0.28.0",
"@expo/react-native-action-sheet": "^3.12.0",
"@gorhom/bottom-sheet": "4.6.0",
"@helium/account-fetch-cache": "0.10.3",
"@helium/account-fetch-cache-hooks": "0.10.3",
"@helium/address": "^4.10.2",
"@helium/crypto-react-native": "^4.10.2",
"@helium/currency": "^4.10.2",
"@helium/helium-entity-manager-sdk": "0.10.3",
"@helium/helium-react-hooks": "0.10.3",
"@helium/helium-sub-daos-sdk": "0.10.3",
"@helium/http": "^4.10.2",
"@helium/lazy-distributor-sdk": "0.10.3",
"@helium/onboarding": "4.14.0",
"@helium/proto-ble": "^4.11.1",
"@helium/react-native-sdk": "^3.1.0",
"@helium/spl-utils": "0.10.3",
"@helium/sus": "0.10.3",
"@helium/transactions": "^4.10.2",
"@helium/wallet-link": "^4.11.0",
"@metaplex-foundation/mpl-token-metadata": "2.10.0",
"@pythnetwork/client": "2.17.0",
"@react-native-async-storage/async-storage": "^1.16.1",
"@react-native-community/blur": "^4.3.0",
"@react-native-community/clipboard": "^1.5.1",
"@react-native-community/netinfo": "^8.1.0",
"@react-native-community/push-notification-ios": "^1.10.1",
"@react-native-firebase/analytics": "^14.11.1",
"@react-native-firebase/app": "^14.11.1",
"@react-native-masked-view/masked-view": "^0.2.6",
"@react-navigation/bottom-tabs": "5.11.3",
"@react-navigation/drawer": "5.12.9",
"@react-navigation/material-top-tabs": "^6.3.0",
"@react-navigation/native": "^5.8.4",
"@react-navigation/stack": "^5.12.1",
"@reduxjs/toolkit": "^1.4.0",
"@rnmapbox/maps": "10.1.36",
"@sentry/react-native": "^6.8.0",
"@shopify/restyle": "^1.3.1",
"@solana/spl-account-compression": "0.1.4",
"@solana/spl-token": "0.3.6",
"@solana/wallet-adapter-react": "0.15.33",
"@solana/web3.js": "1.87.6",
"@types/tinycolor2": "^1.4.3",
"@wutiange/log-listener-plugin": "^2.0.2",
"@wutiange/mapboxgl-api": "^1.0.0-alpha.4",
"@wutiange/react-actions": "^0.0.1-alpha.3",
"angry-purple-tiger": "^1.0.5",
"aws-amplify": "^4.3.15",
"aws-amplify-react-native": "^6.0.3",
"axios": "^1.6.8",
"base-64": "^1.0.0",
"bignumber.js": "^9.1.1",
"bn.js": "5.2.1",
"buffer": "^6.0.3",
"compare-versions": "^3.6.0",
"crypto-js": "^4.1.1",
"date-fns": "^2.16.1",
"decimal.js": "^10.3.1",
"expo": "^47.0.0",
"expo-barcode-scanner": "12.1.0",
"expo-camera": "13.1.0",
"expo-haptics": "12.0.1",
"expo-linking": "3.3.0",
"expo-local-authentication": "13.0.2",
"expo-location": "15.0.1",
"expo-permissions": "14.0.0",
"expo-splash-screen": "0.17.5",
"fuse.js": "^6.4.6",
"geojson2h3": "^1.1.1",
"git": "^0.1.5",
"h3-js": "^4.1.0",
"i18next": "^19.8.3",
"javascript-time-ago": "^2.5.4",
"lodash": "^4.17.20",
"lottie-react-native": "^4.0.2",
"number-to-locale-string-polyfill": "^1.0.9",
"parse5": "^6.0.1",
"patch-package": "^6.4.7",
"postinstall-postinstall": "^2.1.0",
"protobufjs": "^6.10.2",
"qs": "^6.9.6",
"query-string": "^7.0.0",
"react": "^18.1.0",
"react-async-hook": "^3.6.2",
"react-i18next": "^11.7.3",
"react-native": "^0.70.15",
"react-native-animatable": "^1.3.3",
"react-native-appstate-hook": "^1.0.6",
"react-native-ble-plx": "^2.0.3",
"react-native-code-push": "^7.0.4",
"react-native-config": "^1.4.1",
"react-native-device-info": "^8.4.4",
"react-native-emoji": "^1.8.0",
"react-native-gesture-handler": "1.10.3",
"react-native-get-random-values": "^1.7.0",
"react-native-html-to-pdf": "^0.12.0",
"react-native-keyboard-aware-scroll-view": "^0.9.4",
"react-native-linear-gradient": "^2.8.3",
"react-native-localize": "^1.4.3",
"react-native-mail": "^6.1.1",
"react-native-navigation-bar-color": "^2.0.1",
"react-native-orientation-locker": "^1.5.0",
"react-native-pager-view": "~6.0.1",
"react-native-popover-view": "^5.1.7",
"react-native-reanimated": "^2.13.0",
"react-native-safe-area-context": "^3.1.8",
"react-native-screens": "^2.12.0",
"react-native-simple-toast": "^1.1.3",
"react-native-skeleton-placeholder": "^3.0.2",
"react-native-snap-carousel": "^4.0.0-beta.6",
"react-native-svg": "^12.1.1",
"react-native-tab-view": "^3.3.0",
"react-native-text-ticker": "^1.12.0",
"react-native-webview": "^11.15.0",
"react-native-zohodesk-portal-sdk": "^1.0.9",
"react-qr-code": "^1.0.3",
"react-redux": "^7.2.2",
"react-time-ago": "^7.2.1",
"react-timestamp": "^5.3.0",
"redux-flipper": "^2.0.1",
"redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0",
"rn-swipe-button": "^1.3.6",
"sensecapmx-dashboard-utils": "https://iteam-gitlab.seeed.cn/sensecapmx-private/sensecapmx-dashboard-utils.git#78a448d",
"tinycolor2": "^1.4.2",
"use-debounce": "^10.0.0",
"use-state-with-callback": "^2.0.3"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/plugin-proposal-logical-assignment-operators": "^7.20.7",
"@babel/runtime": "^7.12.5",
"@commitlint/cli": "^17.5.1",
"@commitlint/config-conventional": "^17.4.4",
"@react-native-community/eslint-config": "^2.0.0",
"@testing-library/jest-native": "^5.4.3",
"@testing-library/react-hooks": "^8.0.1",
"@testing-library/react-native": "^12.4.3",
"@types/base-64": "^0.1.3",
"@types/bn.js": "5.1.1",
"@types/crypto-js": "^4.0.2",
"@types/geojson": "^7946.0.7",
"@types/i18n-js": "^3.0.3",
"@types/jest": "^25.2.3",
"@types/lodash": "^4.14.165",
"@types/parse5": "^5.0.3",
"@types/qs": "^6.9.5",
"@types/react-native": "^0.63.2",
"@types/react-redux": "^7.1.11",
"@types/react-test-renderer": "^16.9.2",
"@types/webpack-env": "^1.15.3",
"@typescript-eslint/eslint-plugin": "^4.1.0",
"@typescript-eslint/parser": "^4.1.0",
"app-icon": "^0.13.2",
"babel-jest": "^27.0.2",
"babel-plugin-module-resolver": "^3.2.0",
"babel-preset-react-native": "^4.0.1",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-airbnb-typescript": "^10.0.0",
"eslint-config-prettier": "^6.11.0",
"eslint-config-react-app": "^5.2.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.0.2",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react-hooks": "^4.1.2",
"husky": "^7.0.0",
"jest": "^27.0.4",
"jest-circus": "^27.0.4",
"jest-expo": "^41.0.0",
"lint-staged": "^10.5.1",
"metro-react-native-babel-preset": "0.72.3",
"prettier": "^2.0.5",
"prettier-eslint": "^11.0.0",
"react-native-bundle-visualizer": "^3.1.1",
"react-native-cli-bump-version": "^1.1.0",
"react-native-flipper": "^0.137.0",
"react-native-svg-transformer": "^0.14.3",
"react-test-renderer": "18.1.0",
"reactotron-react-native": "^5.0.0",
"reactotron-redux": "^3.1.3",
"ts-jest": "^27.1.4",
"typescript": "^4.6.4"
},
"resolutions": {
"@types/react": "17.0.43",
"@solana/spl-token": "0.3.6",
"@helium/currency-utils": "0.6.42",
"@solana/wallet-adapter-react": "0.15.33",
"@helium/account-fetch-cache": "0.10.3",
"@helium/account-fetch-cache-hooks": "0.10.3",
"@helium/helium-react-hooks": "0.10.3",
"@helium/voter-stake-registry-hooks": "0.10.3",
"@helium/voter-stake-registry-sdk": "0.10.3",
"@helium/modular-governance-hooks": "^0.1.5",
"@helium/onboarding": "4.14.0",
"@helium/react-native-sdk": "3.0.0"
},
"jest.preset": "react-native",
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
```
However, it still doesn't work.
So, I started to think that the upgrade might have caused all the dependencies in my project to throw errors. I removed all the Helium-related code, and the app ran normally, confirming that the issue was indeed caused by upgrading Helium.
Then, I considered that it might be an issue with Metro loading. I referred to your example app and found it to be the same. Below is my `metro.config.js`:
```javascript
const { getDefaultConfig } = require('metro-config')
const { createSentryMetroSerializer } = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');
module.exports = (async () => {
const {
resolver: { sourceExts, assetExts },
} = await getDefaultConfig()
return {
transformer: {
babelTransformerPath: require.resolve('react-native-svg-transformer'),
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
resolver: {
assetExts: assetExts.filter((ext) => ext !== 'svg'),
sourceExts: ['cjs', ...sourceExts, 'svg'],
},
serializer: {
customSerializer: createSentryMetroSerializer(),
},
}
})()
```
Even after all this, the issue still persists.
Then I thought it might be an issue during the Babel transformation, but after checking, I didn’t find anything. Below is my `babel.config.js`.
function getAliasesFromTsConfig() {
const tsConfig = require('./tsconfig.json')
const paths = tsConfig.compilerOptions.paths
let alias = {}
Object.keys(paths).forEach((key) => {
alias[key] = `./${paths[key][0]}`
})
alias['@'] = './src'
return alias
}
const baseConfig = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
[
'module-resolver',
{
alias: getAliasesFromTsConfig(),
extensions: ['.ios.js', '.android.js', '.js', '.ts', '.tsx', '.json'],
root: ['./src'],
},
],
'@babel/plugin-proposal-logical-assignment-operators'
],
}
module.exports = (api) => {
api.cache(true)
return {
...baseConfig,
plugins: [
...baseConfig.plugins,
'react-native-reanimated/plugin'
],
}
}
I really can't think of any other way to troubleshoot this, so I'm asking here because you might be able to help. If this doesn't work, I might have to read the Metro source code, which will take more time and prevent me from completing the task.
Contributor guide
Assessment
This issue has not been assessed yet.