Ran into quite a few issues and limitations sadly.
The css interpolation function is still required if you want to execute logic statements or curried functions. Slightly more info in the official docs: styled-components.com/docs/api#css
Also the syntax highlighting breaks if you place the opening backtick that comes after (props) => on a new line. Unfortunately Prettier automatically places the entire inner interpolation function on its own line grrr 😝
Unfortunately no clean way to get syntax highlighting for the third option - at least in VSCode.
Other than that though, yeah, this is a very common way to access props and it's a very well hidden trick indeed.
It works in TypeScript though:
Ran into quite a few issues and limitations sadly.
The
css
interpolation function is still required if you want to execute logic statements or curried functions. Slightly more info in the official docs: styled-components.com/docs/api#cssAlso the syntax highlighting breaks if you place the opening backtick that comes after
(props) =>
on a new line. UnfortunatelyPrettier
automatically places the entire inner interpolation function on its own line grrr 😝simple template literal (without
css
):Sadly, but yes highlighting is broken in many cases
Huh, neat, thanks for sharing! Looks like syntax highlighting does indeed play nice when you add any sort of typings.
Guess what I'll be working on this Monday morning :)