这是我的根本组成部分:
const App = () => (
<Provider store={store}>
<PersistGate persistor={persistor} loading={<LoadingView />}>
<MainTabNavigator />
</PersistGate>
</Provider>
)
export default App
Run Code Online (Sandbox Code Playgroud)
还有一个非常简单的快照测试:
describe('Testing root App component', () => {
test('Renders as expected', () => {
const tree = renderer.create(<App />).toJSON()
expect(tree).toMatchSnapshot()
})
})
Run Code Online (Sandbox Code Playgroud)
当我运行测试时,它通过了,但下面显示了此错误消息:
PASS __tests__/App.test.tsx
? Console
console.error node_modules/react-test-renderer/cjs/react-test-renderer.development.js:5190
The above error occurred in the <TabView> component:
in TabView (created by withCachedChildNavigation(TabView))
in withCachedChildNavigation(TabView)
in Unknown (created by Navigator)
in Navigator (created by NavigationContainer)
in NavigationContainer (created by App) …Run Code Online (Sandbox Code Playgroud) 我有一个使用bcrypt库的节点项目。当我将其部署到Azure时(在我的本地计算机上运行良好,并且我的计算机和Azure服务器都在运行Node 10.7.0),对于每个请求,我都会收到HTTP错误500。当我检查应用程序日志以了解问题所在时,这是我收到的完整错误消息(减去堆栈跟踪):
Application has thrown an uncaught exception and is terminated:
Error: The module '\\?\D:\home\site\wwwroot\node_modules\bcrypt\lib\binding\bcrypt_lib.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 57. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
Run Code Online (Sandbox Code Playgroud)
我尝试了以下操作,但均未成功:
npm rebuild在Kudu调试控制台上运行node_modules从我的.gitignore中省略,并将机器的节点模块目录直接推到azure(是的,我很拼命)我该如何解决?
我的问题的核心是,当我在navigationOptions中有这个时:
static navigationOptions = ({ navigation }) => {
console.log(navigation)
console.log(navigation.state)
}
Run Code Online (Sandbox Code Playgroud)
第一个'console.log'语句返回带有"navigation.state.params"的导航对象,其中包含我传入的params.
但是,第二个'console.log'返回'navigation.state'对象,但由于某种原因'params'未定义.
以下是我设置导航参数的方法(来自redux):
function mapStateToProps(state, props) {
let sum = 0
for (let product in state.cart) {
sum += state.cart[product]
}
return props.navigation.state = {params: {cartSum: sum}}
}
Run Code Online (Sandbox Code Playgroud)
而我的开发者环境:
节点6.10.1
react-native 0.46.4
redux 3.7.1
react-redux 5.0.5
react-navigation 1.0.0-beta.11
javascript ×2
react-native ×2
azure ×1
backend ×1
jestjs ×1
node-modules ×1
node.js ×1
react-redux ×1
reactjs ×1
redux ×1