GitHub knows how to do JSX syntax highlighting. Since we are using JSX
in this document, I figured we might as well tell GitHub to highlight
the syntax as JSX here. This will lead to a better reading experience.
Screenreaders already announce `img` elements as images, so there is no
need to include this information in the alt text. This will give people
using assistive technologies a smoother experience.
We want our React apps to be accessible. One thing that developers can
do is properly use alt text on images. Thankfully, there is an ESLint
rule that will enforce these things for us.
I think it makes more sense to put static methods above the constructor
in classes. I would like to update the ESLint configuration to match
this, but it looks like the react/sort-comp rule does not support it
quite yet.
https://github.com/yannickcr/eslint-plugin-react/issues/128
I noticed that some newlines and indentation were a little inconsistent
in this file, so I decided to smooth things out a bit. This should help
people who decide to modify this document in the future. When
determining which is the "right" way to format these things, I decided
to use the style used by base readme as a guide.
I noticed a number of places in this document where code was being
referenced but it was not marked as such. Adding backticks will instruct
the markdown parser to format these bits as code, which should improve
the readability of this document.
isMounted is an anti-pattern [0], is not available when using ES6
classes, and is on its way to being officially deprecated.
eslint-plugin-react recently added the react/no-is-mounted rule in
3.12.0 that prevents its use.
[0]: https://facebook.github.io/react/blog/2015/12/16/ismounted-antipattern.html
Finishes #633
When there are static variables like `propTypes` and `defaultProps`, we shouldn't export them until we have actually set them onto the `Component`. This may change if the current ES7 proposal for static class properties gets accepts, and we update to support it.
By exporting `propTypes` as a named export *as well* as attaching them to the "class", they can be explicitly imported by tests and other components in a way that aligns with the future ES6 module dependency graph, rather than as an arbitrary property that isn't statically verifiable. Doing both is great imo.
Thoughts?