我正在關注https://www.npmjs.com/package/react-native-sidebar以實施側邊欄。 I'm getting this error刷新我的iOS
模擬器。我按照現在的方向,但在我的WebStorm IDE
這是說Unresolved function or method renderLeftSideBar()
和Unresolved function or method renderLeftSideBar()
。渲染功能將無法用於側邊欄
下面的代碼:
import React, { Component } from 'react';
import { AppRegistry} from 'react-native';
import { Provider } from 'react-redux';
import Application from './pages/Application';
import store from './redux';
import api from './utilities/api';
import SideBar from 'react-native-sidebar';
export default class DApp extends Component {
constructor(props) {
super(props);
this.state = {
data: [],
isLoading: true
}
console.log("something");
}
componentWillMount() {
api.getData().then((res) => {
this.setState({
data: res.data
})
});
}
renderLeftSideBar() {
return(
<Text>Someting here for left side bar!</Text>
);
}
renderRightSideBar() {
return(
<Text>Someting here for right side bar!</Text>
);
}
renderContent() {
return(
<Text>The content!</Text>
);
}
render() {
if(this.state.isLoading) {
console.log("The data is: " + this.state.data);
} else {
console.log("Else got executed");
}
return (
<Provider store={store}>
<SideBar>
leftSideBar = {this.renderLeftSideBar()}
rightSideBar = {this.renderRightSideBar()}
style = {{flex: 1, backgroundColor: 'black'}}>{this.renderContent()}
</SideBar>
<Application />
</Provider>
);
}
}
AppRegistry.registerComponent('DApp',() => DApp);
定義'renderLeftSideBar','renderRightSideBar'和'renderContent'功能 –
要搞清楚的事情瞭解'this'關鍵字在JavaScript中,同時使用'class'關鍵字如何做到這一點的行爲。 –