root-two / react-native-drawer

React Native Drawer
MIT License
2.54k stars 391 forks source link

I dont understand why this error show #287

Open prakasa1904 opened 7 years ago

prakasa1904 commented 7 years ago

undefined is not an object (evaluating '_this._drawer.close'

I think, my code already same with your sample, :

export default class Simple extends Component { static PropTypes = { title: PropTypes.string.isRequired, setTitle: PropTypes.func.isRequired, setContent: PropTypes.func.isRequired, children: PropTypes.node.isRequired, }

state={ drawerOpen: false, drawerDisabled: false, }

closeDrawer = () => { this._drawer.close() }

openDrawer = () => { this._drawer.open() }

render() { return ( <Drawer ref={(ref) => this._drawer = ref} type='static' styles={drawerStyles} content={} onOpen={() => { this.setState({drawerOpen: true}) }} onClose={() => { this.setState({drawerOpen: false}) }} disabled={this.state.drawerDisabled} openDrawerOffset={(viewport) => { return 100 }} closedDrawerOffset={() => 50}

<ContentLayout openDrawer={this.openDrawer}

{ this.props.children } ) } }

prakasa1904 commented 7 years ago

here my depends :

"dependencies": { "@expo/vector-icons": "^4.0.0", "native-base": "^2.1.1", "react": "16.0.0-alpha.6", "react-native": "0.43.2", "react-native-gifted-listview": "0.0.15", "react-native-gridview": "^0.1.1", "react-native-loading-spinner-overlay": "^0.4.4", "react-native-menu": "^0.20.2", "react-native-rest-client": "^0.1.1", "react-native-vector-icons": "^4.0.1" },

should I changes same as example ?

prakasa1904 commented 7 years ago

done with this issues, I think we need update example ref with props only. Coz, every render ref return undefined.

just changes open with our component state and changes it with some function there.

teameh commented 7 years ago

Your code is not really readable for anyone. You can add formatting by wrapping it in ``` blocks, see https://help.github.com/articles/basic-writing-and-formatting-syntax/#quoting-code