Error when trying to register headless task in library
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 25/100
- Issue 類型
- 缺陷
- 描述清晰度
- 需要釐清
- 活躍度
- 停滯
- 技術堆疊
- javascript, react-native
- 領域
- mobile-dev, tooling
研究方向
首先根據連結的 repro 重現問題,並將 example/index.js 中的 AppRegistry 結果與 library wrapper 中的結果進行比較。檢查 create-react-native-library 的 turbo-module setup 如何解析 React Native,接著驗證透過該函式庫進行的 headless 工作註冊能在沒有重複 React Native 實例的情況下正常運作。
由索引模型根據 Issue 內容生成。
描述
Description
Hi!
I'm trying to create a wrapper around the AppRegistry.registerHeadlessTask function in my library like this:
export function setBackgroundMessageHandler(handler: BackgroundMessageHandler) {
AppRegistry.registerHeadlessTask('MediaControlsHeadlessTask', () => handler);
}
And this is in the example/index,js:
setBackgroundMessageHandler(require('./src/handler'));
This results in the following errors:
E Invariant Violation: "MediaControlsExample" 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
E ExceptionsManager should be set up after React DevTools to avoid console.error arguments mutation
E TypeError: property is not writable, js engine: hermes
E TypeError: Cannot read property 'default' of undefined, js engine: hermes
Calling AppRegistry.registerHeadlessTask in the example/index.js directly works. It seems like AppRegistry points to two react-native instances?! E.g. when printing AppRegistry.getAppKeys(), I get different results in the example/index.js and the library.
Packages
- create-react-native-library
- react-native-builder-bob
Selected options
"create-react-native-library": {
"languages": "kotlin-objc",
"type": "turbo-module",
"version": "0.52.0"
}
Link to repro
https://github.com/mbpictures/react-native-media-notification/tree/feat/android-auto-library
Environment
info Fetching system and libraries information...
System:
OS: Windows 11 10.0.26100
CPU: (24) x64 13th Gen Intel(R) Core(TM) i7-13700K
Memory: 3.77 GB / 31.77 GB
Binaries:
Node:
version: 22.16.0
path: C:\Program Files\nodejs\node.EXE
Yarn:
version: 3.6.1
path: ~\AppData\Roaming\npm\yarn.CMD
npm:
version: 8.12.2
path: C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK:
AllowAllTrustedApps: Enabled
AllowDevelopmentWithoutDevLicense: Enabled
Versions:
- 10.0.19041.0
- 10.0.22000.0
IDEs:
Android Studio: Not Found
Visual Studio:
- 16.11.35026.282 (Visual Studio Community 2019)
- 17.10.35122.118 (Visual Studio Community 2022)
Languages:
Java: 17.0.9
Ruby:
version: 3.2.3
path: C:\Ruby32-x64\bin\ruby.EXE
npmPackages:
"@react-native-community/cli":
installed: 18.0.0
wanted: 18.0.0
react:
installed: 19.0.0
wanted: 19.0.0
react-native:
installed: 0.79.2
wanted: 0.79.2
react-native-windows: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
info React Native v0.81.0 is now available (your project is running on v0.79.2).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.81.0
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.79.2&to=0.81.0
info For more info, check out "https://reactnative.dev/docs/upgrading?os=windows".
- 主要語言
- JavaScript
- 星號
- 3.2k
- 分支
- 229
- 平均合併
- 2 天 15 小時
- 30 天內合併 PR
- 5
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
callstack/react-native-builder-bob 的其他 Issue
-
難度 3/5 1-2 天 新手友好度 42/100
callstack/react-native-builder-bob#901 · 1 則留言 ·
-
bug
難度 3/5 1-2 天 新手友好度 42/100
callstack/react-native-builder-bob#896 · 2 則留言 ·
-
bug
難度 3/5 1-2 天 新手友好度 42/100
callstack/react-native-builder-bob#852 · 1 則留言 · 1 個 reaction ·
-
bug
難度 4/5 3-5 天 新手友好度 35/100
callstack/react-native-builder-bob#829 · 20 則留言 ·
-
bug
難度 4/5 3-5 天 新手友好度 35/100
callstack/react-native-builder-bob#817 · 5 則留言 ·
查看 callstack/react-native-builder-bob 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 64/100
-
bug code-annotation
難度 2/5 1-3 小時 新手友好度 76/100
quarto-dev/quarto-cli#15215 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 70/100
521xueweihan/HelloGitHub#4133 ·
-
難度 1/5 1-3 小時 新手友好度 88/100
-
enhancement
難度 2/5 1-3 小時 新手友好度 68/100
Hugo-SA/receita-random#20 ·
維護者通常 1 天內回覆