我正试图在我的project https://github.com/rt2zz/react-native-drawer中使用这个插件.我可以正确运行这个示例,但在集成它时遇到了问题.
我在方法openDrawer中出错."无法读取未定义的属性抽屉"
我猜我没有以正确的方式定义和使用这个类(我是javascript OOP新手),因为在示例中,它使用了React.createClass({
个不同于我的组件作为扩展组件,并具有构造函数.
我班的相关代码如下.
class Search extends Component {
constructor(props) {
super(props);
this.state = {
isLoading: true,
dataSource: new ListView.DataSource({
rowHasChanged: (row1, row2) => row1 !== row2
})
};
}
openDrawer(){
this.refs.drawer.open()
}
getInitialState(){
return {
drawerType: 'overlay',
}
}
你是谁
render() {
if (this.state.isLoading) {
return this.renderLoadingView();
}
var controlPanel = <MyControlPanel closeDrawer={() => {this.refs.drawer.close()}} />
return (
<View>
<View style={styles.topBar}>
<Drawer
ref="drawer"
>
<MyMainView
/>
</Drawer>
<Text style={styles.topBarMenu}>☰</Text>
<Text style={styles.topBarTitle}>เงินปันผล</Text>
<Text style={styles.topBarRight}></Text>
</View>