Reputation: 985
I have a component that has a state inside and is also exported with redux using:
export default connect(mapStateToProps, mapDispatchToProps)(CoinModal)
I am trying to make a reference of this component to access its state using this code:
<CoinModal ref={(modal) => (this.modal = modal)}}
However, when I try to access the state of that using this.modal.state
, it cannot access already since it is exported using redux mapping, is there a way for me to access its state even if its exported as redux?
Upvotes: 0
Views: 41
Reputation: 5167
you can do something like this
inside your class you can have
setModalRef = () => {
this.modal = this.props.modal
}
and then the render() method can have this
<CoinModal ref={this.setModalRef}
Hope this helps
Upvotes: 1
Reputation: 902
The way you are using is wrong, you can pass the state from your current component to CoinModel but you can get state from CoinModel. As CoinModel will be rendered later than your current component.
Upvotes: 0