Drawer ref is undefined
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
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 I'm not using redux but passed refs via props. It's not working. It's like losing reference.