Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drawer ref is undefined #19

Open
munkhorgil opened this issue Dec 24, 2017 · 2 comments
Open

Drawer ref is undefined #19

munkhorgil opened this issue Dec 24, 2017 · 2 comments

Comments

@munkhorgil
Copy link

munkhorgil commented Dec 24, 2017

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

@gaaragots
Copy link

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)) } })

@faustoct1
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants