WICG / document-picture-in-picture

https://wicg.github.io/document-picture-in-picture/
Other
56 stars 9 forks source link

React components support? #85

Open mmarzullotv opened 1 year ago

mmarzullotv commented 1 year ago

Hey guys, I need to create a specific custom Layout UI for the PiP window with React custom components, along with their business logic from hooks, state control and their styles. But I can't seem to find a proper way to do it. Is this even supported by now?

When I tried to move a button element wrapper from parent document to children window, that had event listeners attached to it such as onClick, the event got lost in the process. All the logic behind it as well for like switching visibility or controlled rendering based on some component state. It even replaced it for "null" for a different state rendering in the button. (Simple "Play" | "Pause" button element switching)

Any help related to this matter would be greatly appreciated. Keep up the good work!

egm0121 commented 1 year ago

you can use defintely render react components from your react app inside a PiP window by using a react portal, see: https://react.dev/reference/react-dom/createPortal