Skip to content

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

Closed
@dum3ng

Description

@dum3ng

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions