I have a web application written in classic HTML/CSS/jQuery. I am writing a chat overlay (similar to the Facebook chat overlay) which needs to be highly interactive. I initially wrote this using Vue, but I decided to try re-writing it using React for learning purposes and I'm stuck at one particular part.
I have a component called ChatOverlay, which handles all of the conversations that should be displayed on the page. I render this ChatOverlay in a div with id='chat-footer', which is just a fixed element overlaying the page.
const element = <ChatOverlay name="Testing" conversationId="a6b9bc89-b9ff-4eb1-86d8-ac5986fb5cbe"/>;
ReactDOM.render(
element,
document.getElementById('chat-footer')
);
However, I'm not sure how to interact with the React components from outside the react "environment". For example, I may have a button on the a user's profile which says "chat". For example, consider the following jquery click event handler:
$('.chat-button').on('click', function(){
//I need to tell the react app to open another conversation
});
With Vue, in the click handler, I could easily call a Vue function which can perform some actions in Vue's "environment", however I'm not sure how to achieve the same thing in React. Any advice would be much appreciated.