Skip to content

Instantly share code, notes, and snippets.

@ethan-deng
Last active March 24, 2017 20:44
Show Gist options
  • Save ethan-deng/6ed7d0b1d13c7ef01f6c to your computer and use it in GitHub Desktop.
Save ethan-deng/6ed7d0b1d13c7ef01f6c to your computer and use it in GitHub Desktop.

React Pitfalls

1.React JSX attribute is case sensitive.

For example, this is valid attribute "colSpan". This is not "colspan".

2.When use array to build component JSX, don't set array length to 0 to re-initiate array. Always set array to []. Set array length to 0 will keep the array reference.

3.Don't do this

render: function() {
  return
    <div>something</div>;
}

This will return a empty component. Instead

render: function() {
  return  <div>something</div>;
}

or

render: function() {
  return(
    <div>something</div>
    );
}
  1. Pass number using "{50.23}" instead of "50.23" which will be text.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment