I am having two independent components in react and I want to call a method in first component that returns Some value to another component.
import React from 'react';
export default class A extend React{
constructor(props){
super(props);
}
getName = () =>{
var name = "MyName";
return name;
}
render(){
//Some code to render
}
}
Now In component B in want to call method getName() so that it returns name,which i want to use in component B.
import React from 'react';
export default class B extends React{
constructor(props){
super(props);
}
getName = () =>{
//Want to call the getName method of component A here
}
render(){
//Some code to render
}
}