Skip to content

Instantly share code, notes, and snippets.

@kimberleehowley
Last active March 19, 2021 23:57
Show Gist options
  • Save kimberleehowley/af95575c61f21392cd8760641ace68b9 to your computer and use it in GitHub Desktop.
Save kimberleehowley/af95575c61f21392cd8760641ace68b9 to your computer and use it in GitHub Desktop.
Passing saved audio tracks down to unique tile components in Daily video chat React app
// In Tile.js
export default function Tile(props) {
const videoEl = useRef(null);
const audioEl = useRef(null);
// ...
function getVideoComponent() {
return videoTrack && <video autoPlay muted playsInline ref={videoEl} />;
}
function getAudioComponent() {
return (
!props.isLocalPerson &&
audioTrack && <audio autoPlay playsInline ref={audioEl} />
);
}
// ...
return (
<div className={getClassNames()} onClick={props.onClick}>
<div className="background" />
// ...
{getVideoComponent()}
{getAudioComponent()}
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment