Access ref of a redux connected component

Viewed 899

I used to have a component like this:

class BlahDumb extends Component {
   toggleMe = () => console.log('toggling')
   render() {
      ...
   }
}

I would then use it like this:

class App extends Component {
    doIt = () => this.el.toggleMe()
    refEl = el => this.el = el;
    render() {
       return (
          <div>
              <BlahDumb ref={this.refEl} />
              <button onClick={this.doIt} />
          </div>
       )
    }
}

Now this worked well UNTIL I connected Blah it to redux.

I changed Blah to this:

const Blah = connect(function() { ... })(BlahDumb);

Now I can no longer access toggleMe from this.el that I got via ref. Is this bad pattern? Or is there a way to get a childs refs?

1 Answers
Related