我在发布版本中遇到此错误,而开发版本工作正常。这是我应用的 video。
let neighbors = Array(board.length).fill(Array(board[0].length).fill(0));
// ============================================================================================================
// Put the code for finding the number of neighbors here, inserting it into the corresponding spot in neighbors
// ============================================================================================================
for (let i = 0; i < board.length; i++) {
for (let j = 0; j < board[0].length; j++) {
if (board[i][j] === 1) { // Only change things if conditions are met for death
if (neighbors[i][j] < 2 || 3 < neighbors [i][j]) {
board[i][j]--;
}
} else { // === 0; only change things if conditions are met for new life
if (neighbors[i][j] === 3 {
board[i][j]++;
}
}
}
}
所以我搜索了这个并找到了 this in docs,当我运行 E/ReactNativeJS: Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.
时,这是输出
npm ls react
E:\messenger>npm ls react
messengerMuaz@0.0.1 E:\messenger
+-- @react-native-community/masked-view@0.1.10
| `-- react@16.13.1 deduped
+-- @react-native-firebase/app@11.0.0
| `-- react@16.13.1 deduped
+-- @react-navigation/bottom-tabs@5.11.8
| `-- react@16.13.1 deduped
+-- @react-navigation/native@5.9.3
| +-- @react-navigation/core@5.15.2
| | `-- react@16.13.1 deduped
| `-- react@16.13.1 deduped
+-- @react-navigation/stack@5.14.3
| `-- react@16.13.1 deduped
+-- agora-rn-uikit@3.1.2
| `-- react@16.13.1 deduped
+-- native-base@2.15.2
| +-- @react-native-community/datetimepicker@3.1.1
| | +-- react-native-windows@0.63.23
| | | `-- react@16.13.1 deduped
| | `-- react@16.13.1 deduped
| +-- @react-native-picker/picker@1.9.11
| | `-- react@16.13.1 deduped
| +-- native-base-shoutem-theme@0.3.1
| | `-- react@16.13.1 deduped
| `-- react@16.13.1 deduped
+-- react-native-agora@3.3.2
| `-- react@16.13.1 deduped
+-- react-native-gifted-chat@0.16.3
| +-- @expo/react-native-action-sheet@3.9.0
| | `-- react@16.13.1 deduped
| +-- react-native-parsed-text@0.0.22
| | `-- react@16.13.1 deduped
| +-- react-native-typing-animation@0.1.7
| | `-- react@16.13.1 deduped
| `-- react@16.13.1 deduped
+-- react-native-image-picker@3.3.2
| `-- react@16.13.1 deduped
+-- react-native-reanimated@2.0.0
| `-- react@16.13.1 deduped
+-- react-native-safe-area-context@3.2.0
| `-- react@16.13.1 deduped
+-- react-native-screens@2.18.1
| `-- react@16.13.1 deduped
+-- react-native-svg@12.1.0
| `-- react@16.13.1 deduped
+-- react-native@0.63.4
| +-- react@16.13.1 deduped
| `-- use-subscription@1.5.1
| `-- react@16.13.1 deduped
+-- react-redux@7.2.2
| `-- react@16.13.1 deduped
+-- react-test-renderer@16.13.1
| `-- react@16.13.1 deduped
`-- react@16.13.1
是否导致错误?如果是,请指导我如何解决?