0

I want to use method getMuseumsList() from MuseumData class in MuseumTable class.

The both class is in different file.

MuseumData.js

 class MuseumData extends React.Component {
    constructor() {
        super();
    }

    getMuseumList() {
        return ("TEST");
    }



}

MuseumTable.js

class MuseumTable extends React.Component {
    constructor() {
        super();
    }

    render() {

    }

}
andika_kurniawan
  • 511
  • 4
  • 9
  • 20
  • I react, component can share methods if they have parent-child relationship. Else you can't. – Ved Mar 27 '17 at 05:02
  • Is the files by chance parent-child? If yes, you can simply pass the method from parent using props – DroidNoob Mar 27 '17 at 05:03
  • Ideally you should have a third file from which you should export that function, import that file in both the react class files and use it there. – Rishikesh Dhokare Mar 27 '17 at 05:03
  • so many answers available on SO for the same ques, so instead of asking new ques first try those, if that doesn't help then include the link of those ques and ask a new one, check this also: http://stackoverflow.com/questions/31612598/call-a-react-component-method-from-outside – Mayank Shukla Mar 27 '17 at 05:06
  • Thanks everyone.... – andika_kurniawan Mar 27 '17 at 05:55

0 Answers0