react-native - null 不是对象(评估“this.nativeCommandsModule.push”)
问题描述
我正在使用 WIX-React-Native-Navigation 并在堆栈中推送组件时收到此错误。 错误
有一件事要说,我在 WIX-React-Native-Navigation 中使用Viro-React ARScene Navigation ( Scene Navigation )。
这是我的代码 index.js
import { AppRegistry } from 'react-native';
var OpenDoor = require('./app/base')
import Stack from './app/navigation';
import { Navigation } from "react-native-navigation";
AppRegistry.registerComponent('ViroSample', () => OpenDoor);
Navigation.events().registerAppLaunchedListener(() => {
Navigation.setRoot({
root: {
stack: Stack
}
});
});
导航.js
import { Navigation } from "react-native-navigation";
import Base from './base';
import Menu from './components/Menu/menu';
Navigation.registerComponent('Base', () => Base);
Navigation.registerComponent('Menu', () => Menu);
const Stack = {
children: [{
component: {
name: 'Base'
},
}
]
};
export default Stack;
base.js
import React, {Component} from 'react';
import {
Alert,
View
} from 'react-native';
import {ViroARSceneNavigator} from 'react-viro';
import { Navigation } from 'react-native-navigation';
import APIKeys from './index';
import Camera from './components/Camera/camera';
import MenuButton from './components/Menu/menu_button';
class Base extends Component {
constructor(props) {
super(props);
this.navigateScreen = this.navigateScreen.bind(this);
}
navigateScreen(location) {
Navigation.push(this.props.componentId, {
component: {
name: location
}
});
}
render() {
return(
<View style={styles.container}>
<ViroARSceneNavigator
initialScene = {{
scene: Camera
}}
apiKey = {APIKeys.ViroReact}
style = {styles.ar_scene}
/>
<MenuButton navigation={this.navigateScreen}/>
</View>
);
}
};
const styles = {
container: {
flex: 1
}
};
export default Base;
module.exports = Base;
纠正我,如果我在某个地方错了。
我正在做的是创建一个应用程序,用户可以在增强现实的帮助下虚拟地装饰家。移动应用程序是在 React-Native 上创建的,而用于增强现实的库是 Viro-React。
所以,当我想从一个屏幕导航到另一个屏幕时,在堆栈中推送组件时,我收到了这个错误。谢谢。
解决方案
推荐阅读
- .net - EF Core 可以映射 GET(计算)属性吗?
- sql - 大型数据库在 SQLite 中是否高效?
- perl - 使用 Mechanize 发布没有名称的表单
- bash - GNU 并行 - 如何处理没有空格或换行的列分隔符?
- recursion - SCHEME::R5RS 递归使用地图
- javascript - 使用 useState 有条件地更新状态的一部分
- javascript - PDF Javascript 提交 PDF 作为电子邮件附件在 Chrome 浏览器中不起作用
- r - tapply 中的错误(y,x,均值,na.rm = TRUE):参数必须具有相同的长度
- javascript - 如何定义 forEach 元素以及为什么在 vanilla javascript 中?
- python - 将 df 中的一列拆分为另一列值