···11-import React, { useRef } from "react";
11+import React, { useContext, useRef } from "react";
22import { LivestreamContext, makeLivestreamStore } from "../livestream-store";
33import { useLivestreamWebsocket } from "./websocket";
44···99 children: React.ReactNode;
1010 src: string;
1111}) {
1212+ const context = useContext(LivestreamContext);
1213 const store = useRef(makeLivestreamStore()).current;
1414+ if (context) {
1515+ // this is ok, there's use cases for having one in another
1616+ // like having a player component that's independently usable
1717+ // but can also be embedded within an entire livestream page
1818+ return <>{children}</>;
1919+ }
1320 (window as any).livestreamStore = store;
1421 return (
1522 <LivestreamContext.Provider value={{ store: store }}>