Points to remember when coding in React

Yesha
1 min readMar 4, 2016
  1. Don’t use jQuery and never try to access DOM directly. Always do that through React.
  2. The lower components should be agnostic of parent components. They should be like pure functions (doing stuff solely based on what is passed to them and not trying to access any outer parent stuff)
  3. Use pure functions always.
  4. Never ever mutate props. They are always to be treated as immutable.
  5. React components can only render a single root node. If you want to return multiple nodes they must be wrapped in a single root.
  6. While using JSX with React always declare components with uppercase first letter. React’s JSX uses the upper vs. lower case convention to distinguish between local component classes and HTML tags.
  7. JSX escapes HTML by default to protect against XSS attacks. Use unicode characters directly if wanna use them.
  8. If you pass properties to native HTML elements that do not exist in the HTML specification, React will not render them. If you want to use a custom attribute, you should prefix it with data-

--

--

Yesha

Software engineer at Google. My 2020 lockdown goal is to read as many books such that I digest that information.