Is there a master list of deprecated react stuff?
Not just meteor specific.
It’s tough to find tutorials that use up-to-date stuff AND best practices…
Is there a master list of deprecated react stuff?
Not just meteor specific.
It’s tough to find tutorials that use up-to-date stuff AND best practices…
Unfortunately I don’t know that there’s much of a master list. However, here are a few things to keep in mind as goes current React best-practices:
class MyComponent extends React.Component
and avoid React.createClass
.React.createClass
.const MyComponent = ({ text, className }) => (
<span className={className}>{text}</span>
)
React.createElement
, etc. if possible.? :
) and logical ORs/ANDs (||
, &&
) but use indentation and parentheses to assist in these being easily understood.ref=
only with a function, not a string.React.Children
when iterating over children.ReactDOM.findDOMNode
. Use ref
instead.this
for all local component functions when using ES6 classes. Do this in the constructor.const MyComponents = React.createClass({
componentWillMount() {
...
},
render() {
...
}
})
render
as the last method in React.createClass
and in ES6 class definition.// When using functional stateless components
const MyComponent = ({ text, name }) => (
...
)
// In your render method
render() {
const { text, name } = this.props;
const { persons } = this.state;
const { onClick } = this;
return (
...
)
}
import/export
instead.Honestly that’s all I can think of off the top of my head. The rest are mostly stylistic points. There are also data-flow concepts. React likes data to flow one-directionally with objects down the totem pole only generating events which are caught by a top-level singleton holding all the data. In an ideal structure only the top object(s) would have states and the rest would be functional stateless components with the exception of controlled inputs. This is mostly opinion but works fairly well with React. It’s a given to use JSX and ES6 with React. Liberally use of destructuring, method notation in objects, classes and using the modules system (import/export) are the way to go.
Hope this helps some.
Thanks.
Maybe I’ll make a list.
Also ESLint will catch many React specific anti-patterns.
Yeah I forgot about that.
I may try to put something together for average humans that is more succinct as it relates to figuring out if a tutorial is out-of-date or not.