Refer another component methods in React

it is very common for us to require a second component controller to access its methods from first component in Angular JS. The framwork does it for us when we use require in our component. My question here is do we have something similar in React, or how can we achieve the same thing in React ? Sample code snippet that I am talking about is below.

angular.module('demoModule', [])
.component('demoComponent1', {
  require: {
    anotherComponent: '^anotherCompoent'
  },
  controller: function() {
    this.$onInit = function() {
      this.anotherComponent.someMethod(this);
      console.log(this);
    };
  },
  templateUrl: 'sample.html'
});

Suggestions are appreciated with thanks.

36 thoughts on “Refer another component methods in React”

Leave a Comment