const [play] = useSound()
const [playBell, bellOptions] = useSound();
const [playBoom, boomOptions] = useSound();
It follows the convention of other React hooks, like useState.
const [ myState, setMyState ] = useState(initalValue);
In this case, the "play" is a function to play the sound, and the next array argument is an object with more useful parameters.
const [ play, args ] = useSound()
I assume it's a workaround/replacement for returning a tuple in vanilla JavaScript.
The syntax you see here is Array Destructuring. This way you access the 0th element directly.
Equivalent of:
const hook = useSound() const play = hook[0]
If you want to just take the 2nd item, you can destructure like this: const [, pause] = useSound().
const [playBell, bellOptions] = useSound();
const [playBoom, boomOptions] = useSound();
It follows the convention of other React hooks, like useState.