1

If you use style-components for reactjs, you'll find this type of syntax.

const Title = styled.h1`
  font-size: 1.5em;
  text-align: center;
  color: palevioletred;
`;

Another reference: CSSjs

const styles = csjs`
  .panel {
    border: 1px solid black;
    background-color: ${green};
  }`;

My Question : How this type of syntax works?


If the syntax look like this (below), it's okay, I can understand that - it is a factory function that take one string parameter.

 const styles = csjs(`
  .panel {
        border: 1px solid black;
   }
 `)

But this syntax functionName'string' is looking really odd.

piet.t
  • 11,718
  • 21
  • 43
  • 52
Ritwick Dey
  • 18,464
  • 3
  • 24
  • 37

0 Answers0