DEV Community

Discussion on: The simplest way to share data between two unrelated Components in react

Collapse
 
nagarajanprince profile image
nagarajanprince

Hi,

I have a question regards this.if I am wrong sorry.i am new in react, the question is without import component how you can access methods above example

// Component A
this.dataHolding.getData(data);

// Component B
let details = this.dataHolding.setData();

can you please give Component A code

Collapse
 
muhammadawaisshaikh profile image
Muhammad Awais • Edited

absolutely as you said, after import I got the access to call the method of that class in the component. without we can't use the class or component in other component.