DEV Community

Cover image for Reviewing the Air BnB React/JSX Style Guide: 1. Basic Rules
Andrew Weisbeck
Andrew Weisbeck

Posted on

Reviewing the Air BnB React/JSX Style Guide: 1. Basic Rules

I love Air Bnb - not only is their app amazing (I love looking at the unique hosting spots like this home suspended from a cliff overhang in Kentucky), but I also love their style guide and keep it handy every time I write code. I would be fair to say that Air BnB would be my dream job.

I thought it would be fun to review each of their style guide rules for React/JSX each day. It's a good review to do and also allows one to meditate upon it's meaning. I find this as a useful way to really nail down good practices.

Day 1: Basic Rules

Here are the basic rules laid out by Air BnB

  • Include only one React component per file. Except for Stateless, or Pure, Components - they allow multiple per file.

    • Set eslint: react/no-multi-comp
  • Always use JSX syntax.

  • Don't use React.createElement unless you're initializing an app from a file that is not JSX.

  • react/forbid-prop-types will allow arrays and objects only if it is explicitly noted what they contain, using arrayOf, objectOf, or shape.

That's all for the basic rules! See you tomorrow

So that's not too bad right? I will meditate upon those and think about what that means for my code.

Image description


Top comments (0)