React releases 15.5.0 today, and this will be the last version starting with 15. React 16.0.0 will be the next release
There are two major changes in 15.5.0:
Independent React. PropTypes
In previous versions, we could use the React.PropTypes API to access some types built into React to check props. In version 15.5.0, this API has been separated into a new package prop-types
Import React from 'React '; class Component extends React.Component { render() { return <div>{this.props.text}</div>; }} Component. PropTypes = {text: the React. PropTypes. String. IsRequired,} after 15.5 / / import the React from 'React'; import PropTypes from 'prop-types'; class Component extends React.Component { render() { return <div>{this.props.text}</div>; } } Component.propTypes = { text: PropTypes.string.isRequired, };Copy the code
About to disable React. CreateClass
In the current version we have three ways of declaring components:
- React.createClass
- JavaScript Function
- ES6 Class
React implemented the createClass method internally because JS did not have a Class. However, ES6 is now popular and classes are fully supported, so React will deprecate the createClass method in future versions.
Of course, if you use ES6 classes to declare components, the original mixins will not be used, so React also provides a separate package for createClass
Var React = require(' React '); var Component = React.createClass({ mixins: [MixinA], render() { return <Child />; }}); Var React = require(' React '); var createReactClass = require('create-react-class'); var Component = createReactClass({ mixins: [MixinA], render() { return <Child />; }});Copy the code
These are the two most significant changes, and the ones that most affect our existing code base. You can still use both apis in 15.5.0, but you’ll see deprecation warnings on the console, and they’ll be completely removed in the next 16.0.0 release.
However, students are not worried, after this change, will be able to “painless helicopter” version 16.0.0.
There are also some changes to tests and add-ons that will not be discussed in detail. If you want to learn more about React, check out React V15.5.0
React 16
- ReactDOM will officially enable Fiber, but the API won’t change, so you’ll probably just experience React faster and render smoother. How to understand the React Fiber architecture?
- The React. CreateClass/PropTypes/React. CreateFactory/React. DOM. * several methods will be removed separation into a single package.
Other changes and development plans can be found on React 15.5 and 16 Umbrella · Issue #8854 · Facebook/React.
You can also get a sneak preview of react 16.0.0 with the following commands
NPM install [email protected]Copy the code
Feel free to weigh in in the comments section.