Context
There is a highly used NPM package called classnames - however I like to keep external dependencies low where possible and I like to know what my code is doing. There is no need to import classnames as you can duplicate the code with the simple function above.
What does .filter(Boolean) do on Arrays?
In short, it's a bit of functional programming which is used to remove false, null and undefined values from an array.