How do I get a reference to a component using React with ES6?
I have a Component A
class ComponentA extends React.Component {
doSomethingInComponentA() {
//do Something here..
}
}
render(<ComponentA />, document.getElementById('container'));
And Another Component B where I want to call ComponentA's method
class ComponentB extends React.Component {
doSomethingInComponentB() {
ComponentAInstance.doSomethingInComponentA()
}
}
How do I get a reference to ComponentA? I have tried using
var ComponentAInstance = render (<ComponentA />,
document.getElementById('container'))
export default ComponentAInstance;
But Since I am using Webpack and ComponentA.jsx is my entry point I get the error
Module not found: Error: a dependency to an entry point is not allowed
Is there any workaround for this?