Hacker News new | ask | show | jobs
by hazz99 2277 days ago
It's the pattern/convention that the React team used for the built-in hooks.

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.