3 comments

  • Cihad TurhanCihad Turhan, over 5 years ago

    First and foremost. CSS is not Javascript. So javascript rules cannot be applied to CSS as it is. Opening a javascript documentation and finding the line

    Avoid using global variables

    doesn't mean you are doing CSS wrong. By design, CSS is a tool for laying out elements and it's OK to have global variables. When you have a blank document, you will have 0 predefined global css rules, but you will have more than 175 global javascript variables. That's one of the reasons to avoid global variables in javascript.

    For a big company like facebook, I see the problems of CSS and finding another solution to them is fine but asserting like *we don't like css, we won't use it so you don't use it too * is something different. You are facebook, do it however you like but don't drive the people into different directions and ruin standards.

    It was a bit different but a couple of months ago, a similar statement came from Paul Chiusano about Elm programming language but he was criticized much.

    What I want to say is, current css is not perfect and not suitable for all purposes but the next web will have verynicebrowserstandards which will handle these kind of problems easily.

    2 points
    • Gajus Kuizinas, almost 5 years ago

      All of these are valid arguments. I don't see Facebook's presentation as a call not to use globals in CSS, though. It is more about being able to isolate CSS when needed, which is a shared goal with Web Components standard. React provides a nice "component" abstraction, while CSS Modules spec (https://github.com/css-modules/css-modules) solves the issue. I have written a library https://github.com/gajus/react-css-modules that brings React components very close to Web Components without any headache about legacy browser support. CSS Modules themselves allow local scoped CSS, which allows better semantic naming, composition pattern that can represent the entire element state, to name but a few benefits. Therefore, hurray for the innovation.

      0 points
  • Andrew LiebchenAndrew Liebchen, over 5 years ago

    Really looking forward to React taking on CSS. Structure, behavior, and style all in one component file! Gonna be amazing.

    0 points