meteor / react-packages

Meteor packages for a great React developer experience
http://guide.meteor.com/react.html
Other
573 stars 158 forks source link

Get component method via ‘refs’ from react-meteor-data constructor #202

Closed Tbutnyakov closed 3 years ago

Tbutnyakov commented 8 years ago

Hello!

How can i get access to component method, wrapped react-meteor-data container?

For example this code will work.

export default class Main extends Component {
    constructor(props) {
        super(props);
    }
    openModal(){
      this.refs.modal.handleToogle()
    }
    render(){
      return(
        <div>
          <a href="#" onClick={this.openModal.bind(this)}>
          <Modal ref="modal" />  
        </div>
      )
    }  
}

export default class Modal extends Component {
  constructor(props){
    super(props);
    this.state = {
      open:false
    }
  }
  handleToogle() {
      this.setState({
          open: !this.state.open
      });
  }
}

But if i will wrap Modal component via create container i will can't get access for Modal methods. Instead in 'ref' will store react-meteor-data constructor...

How can i get access to component methods directly? Thank you!

thijssmudde commented 6 years ago

Any update??!?

filipenevola commented 3 years ago

I'm closing this just because it's too old. We can open new issues for items that are still valid.

Most of these items were solved already or replaced by new strategies (like hooks)