export const Button = styled.button``;
Why is there a string right after the field "button" of the object "styled"? How is this valid JS? What does it do?
export const Button = styled.button``;
Why is there a string right after the field "button" of the object "styled"? How is this valid JS? What does it do?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
JS syntactic sugar complexity is getting out of hand.
> How is this valid JS? What does it do?
I'm curious if Python (or a similar whitespace-sensitive syntax) is your first/familiar programming language.
The extra whitespace here does nothing.
The semicolon in JS is an (optional) expression separator, similar to in Bash/Shell. It can occur at the end of a line or at the beginning of a line, or in between lines. Or in between two expressions on a single line. Any whitespace chars before or after it are irrelevant/ignored.
Their question was:
>Why is there a string right after the field "button" of the object "styled"?
which unambiguously refers to the double backtick characters between "styled.button" and the semicolon in this expression:
> export const Button = styled.button``;
That is, in JavaScript, an empty string. There is not whitespace and Python has nothing at all to do with the question. Similarly, an explanation of what a semicolon does in JavaScript does not answer the question.
I also can't answer the question for them as I haven't kept up with newer JavaScript standards, but I thought it important that you realise you misunderstood something here.
Sorry @Traubenfuchs for the misguided explanation.
As another commenter posted, this is a template tag. Technically equivalent to doing something like styled.button('') but the template tag syntax would be used for consistency with other calls in the code (where parameterised template strings would be passed to the button/element/component method)