react-native-drawer-menu icon indicating copy to clipboard operation
react-native-drawer-menu copied to clipboard

Drawer ref is undefined

Open munkhorgil opened this issue 8 years ago • 2 comments

I need to send drawer ref as props, Unfortunately setting ref to variable is async It will be assigned after completion of component render. How can I send drawer ref as props?

<Drawer ref={(ref) => this.drawer = ref}>
   <Router drawer={this.drawer}/>
</Drawer>

in Router this.props.drawer will be undefined

munkhorgil avatar Dec 24 '17 09:12 munkhorgil

Hi,

If you are using redux implemetation you can store ref drawer in state and get it from any place on your app

<Drawer ref={(ref) => ref && this.props.setRefDrawer(ref)}> <Router drawer={this.props.refDrawer}/> </Drawer>

And on the container const mapDispatchToProps(dispatch) => ({ onSetRefDrawer(ref): => { dispatch(setRefDrawer(ref)) } })

gaaragots avatar Dec 30 '17 10:12 gaaragots

@gaaragots I'm not using redux but passed refs via props. It's not working. It's like losing reference.

faustoct1 avatar Apr 16 '19 00:04 faustoct1