当我运行react-native android时,我一直收到此错误Expected dynamic type `double', but had type `null' (Constructing arguments for Timing.createTimer at index 1)
。当我尝试定位Timing.createTimer时,我发现它在node_modules/react-native/Libraries/Core/Timers/JSTimers.js
内的3个位置使用:
1
setTimeout: function(
func: Function,
duration: number,
...args?: any
): number {
if (__DEV__ && IS_ANDROID && duration > MAX_TIMER_DURATION_MS) {
console.warn(
ANDROID_LONG_TIMER_MESSAGE +
'\n' +
'(Saw setTimeout with duration ' +
duration +
'ms)',
);
}
const id = _allocateCallback(
() => func.apply(undefined, args),
'setTimeout',
);
Timing.createTimer(id, duration || 0, Date.now(), /* recurring */ false);
return id;
}
2
setInterval: function(
func: Function,
duration: number,
...args?: any
): number {
if (__DEV__ && IS_ANDROID && duration > MAX_TIMER_DURATION_MS) {
console.warn(
ANDROID_LONG_TIMER_MESSAGE +
'\n' +
'(Saw setInterval with duration ' +
duration +
'ms)',
);
}
const id = _allocateCallback(
() => func.apply(undefined, args),
'setInterval',
);
Timing.createTimer(id, duration || 0, Date.now(), /* recurring */ true);
return id;
}
3
requestAnimationFrame: function(func: Function) {
const id = _allocateCallback(func, 'requestAnimationFrame');
Timing.createTimer(id, 1, Date.now(), /* recurring */ false);
return id;
}
调用方法是在JavaMethodWrapper.java
368行
@Override
public void invoke(JSInstance jsInstance, ReadableNativeArray parameters) {
....
try {
for (; i < mArgumentExtractors.length; i++) {
mArguments[i] = mArgumentExtractors[i].extractArgument(
jsInstance, parameters, jsArgumentsConsumed);
jsArgumentsConsumed += mArgumentExtractors[i].getJSArgumentsNeeded();
}
} catch (UnexpectedNativeTypeException e) {
throw new NativeArgumentsParseException(
e.getMessage() + " (constructing arguments for " + traceName + " at argument index " +
getAffectedRange(jsArgumentsConsumed, mArgumentExtractors[i].getJSArgumentsNeeded()) +
")",
e);
}
....
}
它是从JavaModuleWrapper.java
162
@DoNotStrip
public void invoke(int methodId, ReadableNativeArray parameters) {
if (mMethods == null || methodId >= mMethods.size()) {
return;
}
mMethods.get(methodId).invoke(mJSInstance, parameters);
}
我尝试的事情:
if (id == null || id = '') { return null }
任何帮助将不胜感激。提前致谢
PS:我读到有关此问题的每个帖子都找不到适用的解决方案
答案 0 :(得分:0)
您应该在此处尝试解决方案(针对不同用户的多种解决方案): https://github.com/react-navigation/react-navigation/issues/2387
弄清楚我的问题是什么,但是很奇怪。.我只有一个正确的V形图标,因此我在后退按钮上应用了180度旋转变换。.当我按下goBack时,我有这个相同的错误:TypeError:预期的动态类型为'double',但类型为'string'。