gpt4 book ai didi

react-native - 不变违规: Calling synchronous methods on native modules is not supported in Chrome

转载 作者:行者123 更新时间:2023-12-03 14:47:48 24 4
gpt4 key购买 nike

我已经 fork 了这个React库以与React Native一起使用,并通过安装react-native-svguse-elapsed-time和prop-types使它起作用:

https://github.com/vydimitrov/react-countdown-circle-timer

但是我现在无法使用调试器:

Invariant Violation: Calling synchronous methods on native modules is not supported in Chrome.

Consider providing alternative methods to expose this method in debug mode, e.g. by exposing constants ahead-of-time.

This error is located at: in CountdownCircleTimer (at AppRoot.js:118) in AppRoot (at App.js:9) in Provider (at App.js:8) in App (at renderApplication.js:40) in RCTView (at AppContainer.js:101) in RCTView (at AppContainer.js:119)



我一直在高低搜索有关可能导致错误的软件包的任何线索,我只能看到报告的与 react-native-device-info相关的问题,但这不会引起问题。该错误是什么意思,如果周围只有很少的信息,我该如何开始调试它?

最佳答案

这是临时修复。这在我这边工作得很好。您必须编辑此文件node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js

callNativeSyncHook(
moduleID: number,
methodID: number,
params: any[],
onFail: ?Function,
onSucc: ?Function,
): any {
const isDebuggingEnabled = (typeof atob !== 'undefined');
this.processCallbacks(moduleID, methodID, params, onFail, onSucc);
if(!isDebuggingEnabled)
{
return global.nativeCallSyncHook(moduleID, methodID, params);
}
}
您还可以使用 patch-package对其进行永久性修补。
underlaying issue

关于react-native - 不变违规: Calling synchronous methods on native modules is not supported in Chrome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61067004/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com