我怀疑光纤有错误
我在0.59的React-Native中使用了一些Hook。我的反应版本是16.8.3。
flushedNode.next = flushedNode.previous = null;
// Now it's safe to call the callback.
var callback = flushedNode.callback;
var expirationTime = flushedNode.expirationTime;
var priorityLevel = flushedNode.priorityLevel;
var previousPriorityLevel = currentPriorityLevel;
var previousExpirationTime = currentExpirationTime;
currentPriorityLevel = priorityLevel;
currentExpirationTime = expirationTime;
var continuationCallback;
try {
[ this is the mistake ] continuationCallback = callback();
} finally {
currentPriorityLevel = previousPriorityLevel;
currentExpirationTime = previousExpirationTime;
}
现在,让我展示这个错误。
flushedNode is {
callback: 3,
expirationTime: 220678.60500000097,
next: null,
previous: null,
priorityLevel: 3,
__proto__: Object
}
回调应该是一个函数,但是它显示为3
,所以应用程序崩溃了,为什么?
答案 0 :(得分:0)
在最新的不稳定版本中,https://github.com/facebook/react/blob/master/packages/scheduler/src/Scheduler.js#L320
function unstable_scheduleCallback(priorityLevel, callback, options) {
var newTask = {
id: taskIdCounter++,
callback,
...
}
return newTask
}
是的,它应该是您用来计划的回调。并且此回调稍后用于执行workLoop
,https://github.com/facebook/react/blob/master/packages/scheduler/src/Scheduler.js#L185