Skip to content

Web-component to component user communication #150

Discussion options

You must be logged in to vote

Hey. Great question. I am working on a guide and a library for exactly this! The library will make it easy to provide event listeners that tie into the component following familiar React-like patterns.

You can use use a state management system like Redux to coordinate your whole application (guide on this also coming soon), but it sounds like that would be overkill for this project.

In the meantime, the most straightforward way is to define a global function (attached to the window) and tell r2wc the name of that function. Then you can call it within your component as you would any other function prop.

React Component

const MyComponent: React.FC<{ onComplete: () => void }> = ({ onComplete })

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by christopherjbaker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants