Skip to content

Instantly share code, notes, and snippets.

@emanueleDiVizio
Last active May 28, 2020 20:34
Show Gist options
  • Save emanueleDiVizio/7551c453cbcf322930d47362b1890c0e to your computer and use it in GitHub Desktop.
Save emanueleDiVizio/7551c453cbcf322930d47362b1890c0e to your computer and use it in GitHub Desktop.
const CoolButton = () => {
const playerRef = useRef(null);
const onPress = () => {
playerRef.current.play();
};
useEffect(() => {
playerRef.current = loadPlayer('filename.wav');
return () => {
playerRef.current.destroy();
};
}, []);
return (
<Button
title="Play!"
onPress={onPress}
/>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment