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

Could not access customized property of component after using connect() #1809

Closed
dum3ng opened this issue Jun 15, 2016 · 2 comments
Closed

Comments

@dum3ng
Copy link

dum3ng commented Jun 15, 2016

Say a simple example:

class My extends Component{
    constructor(props) {
      super(props)
      this.state = {}
      this.hello=this.hello.bind(this)
    }
    componentDidMount() {
    }
    hello(){
        console.log('hello')
    }
    render(){
        return <View>
        <Text>my ....my</Text>
        <You/>
        </View>
    }
}

And in other components render():

render(){
 return <View>
 <My ref='my'/>
</View>
}

Then I can use

this.refs['my'].hello()

But after connect with redux,

My = connect()(My)

There wil be an error: this.refs.my.hello is not a function.

Anybody know how to fix this?

@agundermann
Copy link

Messing up refs is a known problem with higher order components. Fortunately, connect provides an API that should help here.

@dum3ng
Copy link
Author

dum3ng commented Jun 15, 2016

@taurose . Thanks! Got things right.
Thought I should always check the documentation first..

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