Skip to content

Instantly share code, notes, and snippets.

@kimberleejohnson

kimberleejohnson/Tile.js

Last active Mar 19, 2021
Embed
What would you like to do?
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