React (web framework): Difference between revisions

Content deleted Content added
Tag: New redirect
 
have react directed to it's cs definition of library and framework
Tags: Removed redirect Reverted nowiki added
Line 1:
{{short description|JavaScript library for building user interfaces}}
#REDIRECT [[React (web framework)]]
 
{{Infobox software
{{R from move}}
| name = React
| logo = React-icon.svg
| author = Jordan Walke
| developer = [[Facebook]] and community
| released = {{Start date and age|2013|5|29}}<ref name="initialrelease">{{cite web|url=https://www.youtube.com/watch?v=GW0rj4sNH2w|last1=Occhino|first1=Tom|last2=Walke|first2=Jordan|title=JS Apps at Facebook|website=YouTube|access-date=22 Oct 2018}}</ref>
| latest release version = {{wikidata|property|reference|edit|P348}}
| latest release date = {{start date and age|{{wikidata|qualifier|P348|P577}}}}
| latest preview version =
| latest preview date = <!-- {{Start date and age|2016|04|7}}<ref name="ghrelease"/> -->
| programming language = [[JavaScript]]
| platform = [[Web platform]]
| genre = [[JavaScript library]]
| license = [[MIT License]]
}}
 
'''React''' (also known as '''React.js''' or '''bazingaJS''') is an [[open-source]], [[Front end and back end|front end]], [[JavaScript library]]<ref name="react">{{Cite web|url= https://reactjs.org|title=React - A JavaScript library for building user interfaces.|website=React|access-date=7 April 2018}}</ref> for building [[user interfaces]] or UI components. It is maintained by [[Facebook]] and a community of individual developers and companies.<ref>{{cite web |url=https://www.infoworld.com/article/2608181/javascript/react--making-faster--smoother-uis-for-data-driven-web-apps.html |title=React: Making faster, smoother UIs for data-driven Web apps |last=Krill |first=Paul |date=May 15, 2014 |website=[[InfoWorld]]}}</ref><ref>{{cite web |url=https://www.infoq.com/news/2013/06/facebook-react |title=Facebook's React JavaScript User Interfaces Library Receives Mixed Reviews |last=Hemel |first=Zef |date=June 3, 2013 |website=InfoQ}}</ref><ref>{{cite web |url=https://thenewstack.io/javascripts-history-and-how-it-led-to-reactjs/ |title=JavaScript's History and How it Led To ReactJS |last=Dawson |first=Chris |date=July 25, 2014 |website=The New Stack}}</ref>
React can be used as a base in the development of [[single-page application|single-page]] or mobile applications. However, React is only concerned with state management and rendering that state to the [[Document Object Model|DOM]], so creating React applications usually requires the use of additional libraries for routing.<ref>{{Cite news|url=https://medium.freecodecamp.org/integrating-create-react-app-redux-react-router-redux-observable-bootstrap-altogether-216db97e89a3|title=How to integrate create-react-app with all the libraries you need to make a great app|last=Dere|first=Mohan|date=2018-02-19|work=freeCodeCamp|access-date=2018-06-14}}</ref><ref>{{Cite web|url=https://medium.com/about-codecademy/react-router-to-redux-first-router-2fea05c4c2b7|title=React Router to Redux First Router|last=Samp|first=Jon|date=2018-01-13|website=About Codecademy|access-date=2018-06-14}}</ref> React Router<ref>{{Cite web|url=https://reacttraining.com/react-router|title=React Router: Declarative Routing for React|website=ReactRouterWebsite|language=en|access-date=2019-10-23}}</ref> is an example of such a library.
 
==Basic usage==
The following is a rudimentary example of React usage in HTML with [[React (JavaScript library)#JSX|JSX]] and JavaScript.
<syntaxhighlight lang="html" line="1">
<div id="myReactApp"></div>
 
<script type="text/babel">
function Greeter(props) {
return <h1>{props.greeting}</h1>
}
var App = <Greeter greeting="Hello World!" />;
ReactDOM.render(App, document.getElementById('myReactApp'));
</script>
</syntaxhighlight>
The <code>Greeter</code> function is a React component that accepts a property <code>greeting</code>. The variable <code>App</code> is an instance of the <code>Greeter</code> component where the <code>greeting</code> property is set to <code>'Hello World!'</code>. The <code>ReactDOM.render</code> method then renders our Greeter component inside the [[Document Object Model|DOM]] element with id <code>myReactApp</code>.
 
When displayed in a web browser the result will be
<syntaxhighlight lang="html">
<div id="myReactApp">
<h1>Hello World!</h1>
</div>
</syntaxhighlight>
 
==Notable features==
===Components===
React code is made of entities called components. Components can be rendered to a particular element in the [[Document Object Model|DOM]] using the React DOM library. When rendering a component, one can pass in values that are known as "props":<ref>{{cite web|url=https://reactjs.org/docs/components-and-props.html#props-are-read-only|website=React|title=Components and Props|publisher=Facebook|access-date=7 April 2018}}</ref>
 
<syntaxhighlight lang="js">
ReactDOM.render(<Greeter greeting="Hello World!" />, document.getElementById('myReactApp'));
</syntaxhighlight>
 
The two primary ways of declaring components in React is via functional components and class-based components.
 
=== Functional components ===
Functional components are declared with a function that then returns some JSX.
 
<syntaxhighlight lang="js">
const Greeting = (props) => <div>Hello, {props.name}!</div>;
</syntaxhighlight>
 
=== Class-based components ===
Class-based components are declared using [[ECMAScript|ES6]] classes.
<syntaxhighlight lang="js">
class ParentComponent extends React.Component {
state = { color: 'green' };
render() {
return (
<ChildComponent color={this.state.color} />
);
}
}
</syntaxhighlight>
 
===Virtual DOM===
Another notable feature is the use of a virtual [[Document Object Model]], or virtual DOM. React creates an [[In-memory processing|in-memory]] data-structure cache, computes the resulting differences, and then updates the browser's displayed DOM efficiently.<ref name=workingwiththebrowser>{{cite web |url=https://reactjs.org/docs/refs-and-the-dom.html |title=Refs and the DOM |website=React Blog}}</ref> This process is called '''reconciliation'''. This allows the programmer to write code as if the entire page is rendered on each change, while the React libraries only render subcomponents that actually change. This selective rendering provides a major performance boost.{{citation needed|date=January 2021}} It saves the effort of recalculating the CSS style, layout for the page and rendering for the entire page.{{citation needed|date=January 2021}}
 
=== Lifecycle methods ===
Lifecycle methods use a form of [[hooking]] that allows the execution of code at set points during a component's lifetime.
 
* <code>shouldComponentUpdate</code> allows the developer to prevent unnecessary re-rendering of a component by returning false if a render is not required.
* <code>componentDidMount</code> is called once the component has "mounted" (the component has been created in the user interface, often by associating it with a [[Document Object Model|DOM]] node). This is commonly used to trigger data loading from a remote source via an [[API]].
*<code>componentWillUnmount</code> is called immediately before the component is torn down or "unmounted". This is commonly used to clear resource-demanding dependencies to the component that will not simply be removed with the unmounting of the component (e.g., removing any <code>setInterval()</code> instances that are related to the component, or an "[[Event (computing)|eventListener]]" set on the "document" because of the presence of the component)
* <code>render</code> is the most important lifecycle method and the only required one in any component. It is usually called every time the component's state is updated, which should be reflected in the user interface.
 
===JSX===
JSX, or JavaScript [[XML]], is an extension to the JavaScript language syntax.<ref>{{cite web|title=Draft: JSX Specification|url=https://facebook.github.io/jsx/|website=JSX|publisher=Facebook|access-date=7 April 2018}}</ref> Similar in appearance to HTML, JSX provides a way to structure component rendering using syntax familiar to many developers. React components are typically written using JSX, although they do not have to be (components may also be written in pure JavaScript). JSX is similar to another extension syntax created by Facebook for [[PHP]] called [[XHP]].
 
An example of JSX code:
<syntaxhighlight lang="js" line="1">
class App extends React.Component {
render() {
return (
<div>
<p>Header</p>
<p>Content</p>
<p>Footer</p>
</div>
);
}
}
</syntaxhighlight>
 
;Nested elements
Multiple elements on the same level need to be wrapped in a single React element such as the <code><nowiki><div></nowiki></code> element shown above, a fragment delineated by <code><nowiki><Fragment></nowiki></code> or in its shorthand form <code><nowiki><></nowiki></code>, or returned as an array.<ref>{{cite web |url=https://reactjs.org/blog/2017/09/26/react-v16.0.html#new-render-return-types-fragments-and-strings |title=React v16.0§New render return types: fragments and strings |last=Clark |first=Andrew |date=September 26, 2017 |website=React Blog}}</ref><ref>{{cite web |url=https://reactjs.org/docs/react-component.html#render |title=React.Component: render |website=React}}</ref>
 
;Attributes
JSX provides a range of element attributes designed to mirror those provided by HTML. Custom attributes can also be passed to the component.<ref>{{cite web |url=https://reactjs.org/blog/2017/09/26/react-v16.0.html#support-for-custom-dom-attributes |title=React v16.0§Support for custom DOM attributes |last=Clark |first=Andrew |date=September 26, 2017 |website=React Blog}}</ref> All attributes will be received by the component as props.
 
;JavaScript expressions
JavaScript [[Expression (computer science)|expressions]] (but not [[Statement (computer science)|statements]]) can be used inside JSX with curly brackets <code>{}</code>:
<syntaxhighlight lang="js">
<h1>{10+1}</h1>
</syntaxhighlight>
 
The example above will render
<syntaxhighlight lang="html">
<h1>11</h1>
</syntaxhighlight>
 
;Conditional statements
[[Conditional (computer programming)|If–else statements]] cannot be used inside JSX but conditional expressions can be used instead.
The example below will render <code>{ i === 1 ? 'true' : 'false' }</code> as the string <code>'true'</code> because <code>i</code> is equal to 1.
<syntaxhighlight lang="js" line="1">
class App extends React.Component {
render() {
const i = 1;
return (
<div>
<h1>{ i === 1 ? 'true' : 'false' }</h1>
</div>
);
}
}
</syntaxhighlight>
The above will render:
<syntaxhighlight lang="html">
<div>
<h1>true</h1>
</div>
</syntaxhighlight>
Functions and JSX can be used in conditionals:
<syntaxhighlight lang="js+genshitext" line="1">
class App extends React.Component {
render() {
const sections = [1, 2, 3];
return (
<div>
{sections.length > 0 && sections.map(n => (
/* 'key' is used by react to keep track of list items and their changes */
/* Each 'key' must be unique */
<div key={"section-" + n}>Section {n}</div>
))}
</div>
);
}
}
</syntaxhighlight>
The above will render:
<syntaxhighlight lang="html">
<div>
<div>Section 1</div>
<div>Section 2</div>
<div>Section 3</div>
</div>
</syntaxhighlight>
 
Code written in JSX requires conversion with a tool such as [[Babel (compiler)|Babel]] before it can be understood by web browsers.<ref>{{Cite book|url=https://books.google.com/books?id=Tg9QDwAAQBAJ|title=React for Real: Front-End Code, Untangled|last=Fischer|first=Ludovico|date=2017-09-06|publisher=Pragmatic Bookshelf|isbn=9781680504484|language=en}}</ref> This processing is generally performed during a [[software build]] process before the application is [[Software deployment|deployed]].
 
===Architecture beyond HTML===
The basic architecture of React applies beyond rendering HTML in the browser. For example, Facebook has dynamic charts that render to <code><nowiki><canvas></nowiki></code> tags,<ref>{{cite web|url=https://facebook.github.io/react/blog/2013/06/05/why-react.html|title=Why did we build React? – React Blog}}</ref> and Netflix and [[PayPal]] use universal loading to render identical HTML on both the server and client.<ref name=paypal-isomorphic-reactjs>{{cite web|title=PayPal Isomorphic React|url=https://medium.com/paypal-engineering/isomorphic-react-apps-with-react-engine-17dae662379c | archive-url=https://web.archive.org/web/20190208124143/https://www.paypal-engineering.com/2015/04/27/isomorphic-react-apps-with-react-engine/ | archive-date=2019-02-08 | url-status=live }}</ref><ref name=netflix-isomorphic-reactjs>{{cite web|title=Netflix Isomorphic React|url=http://techblog.netflix.com/2015/01/netflix-likes-react.html}}</ref>
 
=== React hooks ===
Hooks are functions that let developers "hook into" React state and lifecycle features from function components.<ref>{{Cite web|url=https://reactjs.org/docs/hooks-overview.html|title=Hooks at a Glance – React|website=reactjs.org|language=en|access-date=2019-08-08}}</ref> Hooks don’t work inside classes — they let you use React without classes.<ref>{{Cite web|url=https://blog.soshace.com/what-the-heck-is-react-hooks/|title=What the Heck is React Hooks?|date=2020-01-16|website=Soshace|language=en|access-date=2020-01-24}}</ref>
 
React provides a few built-in hooks like <code>useState</code>,<ref>{{Cite web|url=https://reactjs.org/docs/hooks-state.html|title=Using the State Hook – React|website=reactjs.org|language=en|access-date=2020-01-24}}</ref> <code>useContext</code>, <code>useReducer</code> and <code>useEffect</code>.<ref>{{Cite web|url=https://reactjs.org/docs/hooks-effect.html|title=Using the Effect Hook – React|website=reactjs.org|language=en|access-date=2020-01-24}}</ref> Others are documented in the Hooks API Reference.<ref>{{Cite web|url=https://reactjs.org/docs/hooks-reference.html|title=Hooks API Reference – React|website=reactjs.org|language=en|access-date=2020-01-24}}</ref> <code>useState</code> and <code>useEffect</code>, which are the most used, are for controlling state and side effects respectively.
 
==== Rules of hooks ====
There are rules of hooks<ref>{{Cite web|url=https://reactjs.org/docs/hooks-rules.html|title=Rules of Hooks – React|website=reactjs.org|language=en|access-date=2020-01-24}}</ref> which describe the characteristic code pattern that hooks rely on. It is the modern way to handle state with React.
 
# Hooks should only be called at the top level (not inside loops or if statements).
# Hooks should only be called from React function components, not normal functions or class components
 
Although these rules can't be enforced at runtime, code analysis tools such as linters can be configured to detect many mistakes during development. The rules apply to both usage of hooks and the implementation of custom hooks,<ref>{{Cite web|url=https://reactjs.org/docs/hooks-custom.html|title=Building Your Own Hooks – React|website=reactjs.org|language=en|access-date=2020-01-24}}</ref> which may call other hooks.
 
==Common idioms==
React does not attempt to provide a complete "application library". It is designed specifically for building user interfaces<ref name="react" /> and therefore does not include many of the tools some developers might consider necessary to build an application. This allows the choice of whichever libraries the developer prefers to accomplish tasks such as performing network access or local data storage. Common patterns of usage have emerged as the library matures.
 
===Use of the Flux architecture===
To support React's concept of unidirectional data flow (which might be contrasted with [[AngularJS]]'s bidirectional flow), the Flux architecture represents an alternative to the popular [[model-view-controller]] architecture. Flux features ''actions'' which are sent through a central ''dispatcher'' to a ''store'', and changes to the store are propagated back to the view.<ref name="flux">{{cite web|url=https://facebook.github.io/flux/docs/in-depth-overview.html|title=In Depth OverView|publisher=Facebook|access-date=7 April 2018|website=Flux}}</ref> When used with React, this propagation is accomplished through component properties.
 
Flux can be considered a variant of the [[observer pattern]].<ref>{{cite web|last1=Johnson|first1=Nicholas|title=Introduction to Flux - React Exercise|url=http://nicholasjohnson.com/react/course/exercises/flux/|website=Nicholas Johnson|access-date=7 April 2018}}</ref>
 
A React component under the Flux architecture should not directly modify any props passed to it, but should be passed callback functions that create ''actions'' which are sent by the dispatcher to modify the store. The action is an object whose responsibility is to describe what has taken place: for example, an action describing one user "following" another might contain a user id, a target user id, and the type <code>USER_FOLLOWED_ANOTHER_USER</code>.<ref>{{cite web|last1=Abramov|first1=Dan|title=The History of React and Flux with Dan Abramov|url=http://threedevsandamaybe.com/the-history-of-react-and-flux-with-dan-abramov/|website=Three Devs and a Maybe|access-date=7 April 2018}}</ref> The stores, which can be thought of as models, can alter themselves in response to actions received from the dispatcher.
 
This pattern is sometimes expressed as "properties flow down, actions flow up". Many implementations of Flux have been created since its inception, perhaps the most well-known being [[Redux (JavaScript library)|Redux]], which features a single store, often called a [[single source of truth]].<ref>{{cite web|title=State Management Tools - Results|url=https://stateofjs.com/2017/state-management/results|website=The State of JavaScript|access-date=7 April 2018}}</ref>
 
==Future development==
Project status can be tracked via the core team discussion forum.<ref>{{Cite web|title = Meeting Notes|url = https://discuss.reactjs.org/c/meeting-notes|website = React Discuss|access-date = 2015-12-13}}</ref> However, major changes to React go through the Future of React repository issues and [[pull request]]s.<ref>{{Cite web|title = reactjs/react-future - The Future of React|url = https://github.com/reactjs/react-future|website = GitHub|access-date = 2015-12-13}}</ref><ref>{{Cite web|title = facebook/react - Feature request issues|url = https://github.com/facebook/react/labels/Type:%20Feature%20Request|website = GitHub|access-date = 2015-12-13}}</ref> This enables the React community to provide feedback on new potential features, experimental APIs and JavaScript syntax improvements.
 
==History==
React was created by Jordan Walke, a software engineer at Facebook, who released an early prototype of React called "FaxJS".<ref>{{cite web |last1=Walke |first1=Jordan |title=FaxJS |url=https://github.com/jordwalke/FaxJs |access-date=11 July 2019}}</ref><ref name="papp"/> He was influenced by [[XHP]], an [[HTML]] component library for [[PHP]]. It was first deployed on Facebook's [[News Feed]] in 2011 and later on [[Instagram]] in 2012.<ref>{{cite web|url=https://www.youtube.com/watch?v=A0Kj49z6WdM|title=Pete Hunt at TXJS}}</ref> It was open-sourced at JSConf US in May 2013.<ref name="papp">{{cite news |last1=Papp |first1=Andrea |title=The History of React.js on a Timeline |url=https://blog.risingstack.com/the-history-of-react-js-on-a-timeline/ |access-date=11 July 2019 |work=RisingStack |date=4 April 2018}}</ref>
 
[[React Native]], which enables native [[Android (operating system)|Android]], [[iOS]], and [[Universal Windows Platform|UWP]] development with React, was announced at Facebook's React Conf in February 2015 and open-sourced in March 2015.
 
On April 18, 2017, Facebook announced [[React Fiber]], a new core algorithm of React library for building [[user interface]]s.<ref>{{Cite news|url=https://techcrunch.com/2017/04/18/facebook-announces-react-fiber-a-rewrite-of-its-react-framework/|title=Facebook announces React Fiber, a rewrite of its React library|publisher=TechCrunch|author=Frederic Lardinois|date=18 April 2017|access-date=19 April 2017}}</ref> React Fiber was to become the foundation of any future improvements and feature development of the React library.<ref>{{cite web|title = React Fiber Architecture|url = https://github.com/acdlite/react-fiber-architecture| website=Github|access-date = 19 April 2017}}</ref>{{Update inline|reason=Last commit was in 2016. Is this statement still true?|date=June 2018}}
 
On September 26, 2017, React 16.0 was released to the public.<ref>{{cite web
|url=https://reactjs.org/blog/2017/09/26/react-v16.0.html
|title=React v16.0
|publisher=react.js
|date=2017-09-26
|access-date=2019-05-20
}}</ref>
 
On February 16, 2019, React 16.8 was released to the public.<ref>{{cite web
|url=https://reactjs.org/blog/2017/09/26/react-v16.0.html
|title=React v16.8
|publisher=react.js
|date=2019-02-16
|access-date=2019-05-20
}}</ref> The release introduced React Hooks.<ref>{{cite web
|url=https://reactjs.org/docs/hooks-intro.html
|title=Introducing Hooks
|publisher=react.js
|access-date=2019-05-20
}}</ref>
 
On August 10, 2020, the React team announced the first release candidate for React v17.0, notable as the first major release without major changes to the React developer-facing API.<ref>url=https://reactjs.org/blog/2020/08/10/react-v17-rc.html</ref>
 
{| class="wikitable"
|+Versions
!Version
!Release Date
!Changes
|-
|0.3.0
|29 May 2013
|Initial Public Release
|-
|0.4.0
|20 July 2013
|Support for comment nodes <nowiki><div>{/* */}</div></nowiki>, Improved server-side rendering APIs, Removed React.autoBind, Support for the key prop, Improvements to forms, Fixed bugs.
|-
|0.5.0
|20 October 2013
|Improve Memory usage, Support for Selection and Composition events, Support for getInitialState and getDefaultProps in mixins, Added React.version and React.isValidClass, Improved compatibility for Windows.
|-
|0.8.0
|20 December 2013
|Added support for rows & cols, defer & async, loop for <audio> & <video>, autoCorrect attributes. Added onContextMenu events, Upgraded jstransform and esprima-fb tools, Upgraded browserify.
|-
|0.9.0
|20 February 2014
|Added support for crossOrigin, download and hrefLang, mediaGroup and muted, sandbox, seamless, and srcDoc, scope attributes, Added any, arrayOf, component, oneOfType, renderable, shape to React.PropTypes, Added support for onMouseOver and onMouseOut event, Added support for onLoad and onError on <img> elements.
|-
|0.10.0
|21 March 2014
|Added support for srcSet and textAnchor attributes, add update function for immutable data, Ensure all void elements don't insert a closing tag.
|-
|0.11.0
|17 July 2014
|Improved SVG support, Normalized e.view event, Update $apply command, Added support for namespaces, Added new transformWithDetails API, includes pre-built packages under dist/, MyComponent() now returns a descriptor, not an instance.
|-
|0.12.0
|21 November 2014
|Added new features Spread operator ({...}) introduced to deprecate this.transferPropsTo, Added support for acceptCharset, classID, manifest HTML attributes, React.addons.batchedUpdates added to API, @jsx React.DOM no longer required, Fixed issues with CSS Transitions.
|-
|0.13.0
|10 March 2015
|Deprecated patterns that warned in 0.12 no longer work, ref resolution order has changed, Removed properties this._pendingState and this._rootNodeID, Support ES6 classes, Added API React.findDOMNode(component), Support for iterators and immutable-js sequences, Added new features React.addons.createFragment, deprecated React.addons.classSet.
|-
|0.14.1
|29 October 2015
|Added support for srcLang, default, kind attributes, and color attribute, Ensured legacy .props access on DOM nodes, Fixed scryRenderedDOMComponentsWithClass, Added react-dom.js.
|-
|15.0.0
|7 April 2016
|Initial render now uses document.createElement instead of generating HTML, No more extra <nowiki><span>s, Improved SVG support, ReactPerf.getLastMeasurements() is opaque, New deprecations introduced with a warning, Fixed multiple small memory leaks, React DOM now supports the cite and profile HTML attributes and cssFloat, gridRow and gridColumn CSS properties.</nowiki>
|-
|15.1.0
|20 May 2016
|Fix a batching bug, Ensure use of the latest object-assign, Fix regression, Remove use of merge utility, Renamed some modules.
|-
|15.2.0
|1 July 2016
|Include component stack information, Stop validating props at mount time, Add React.PropTypes.symbol, Add onLoad handling to <nowiki><link></nowiki> and onError handling to <nowiki><source> element, Add isRunning() API, Fix performance regression.</nowiki>
|-
|15.3.0
|30 July 2016
|Add React.PureComponent, Fix issue with nested server rendering, Add xmlns, xmlnsXlink to support SVG attributes and referrerPolicy to HTML attributes, updates React Perf Add-on, Fixed issue with ref.
|-
|15.3.1
|19 August 2016
|Improve performance of development builds, Cleanup internal hooks, Upgrade fbjs, Improve startup time of React, Fix memory leak in server rendering, fix React Test Renderer, Change trackedTouchCount invariant into a console.error.
|-
|15.4.0
|16 November 2016
|React package and browser build no longer includes React DOM, Improved development performance, Fixed occasional test failures, update batchedUpdates API, React Perf, and ReactTestRenderer.create().
|-
|15.4.1
|23 November 2016
|Restructure variable assignment, Fixed event handling, Fixed compatibility of browser build with AMD environments.
|-
|15.4.2
|6 January 2017
|Fixed build issues, Added missing package dependencies, Improved error messages.
|-
|15.5.0
|7 April 2017
|Added react-dom/test-utils, Removed peerDependencies, Fixed issue with Closure Compiler, Added a deprecation warning for React.createClass and React.PropTypes, Fixed Chrome bug.
|-
|15.5.4
|11 April 2017
|Fix compatibility with Enzyme by exposing batchedUpdates on shallow renderer, Update version of prop-types, Fix react-addons-create-fragment package to include loose-envify transform.
|-
|15.6.0
|13 June 2017
|Add support for CSS variables in style attribute and Grid style properties, Fix AMD support for addons depending on react, Remove unnecessary dependency, Add a deprecation warning for React.createClass and React.DOM factory helpers.
|-
|16.0.0
|26 September 2017
|Improved error handling with introduction of "error boundaries", React DOM allows passing non-standard attributes, Minor changes to setState behavior, remove react-with-addons.js build, Add React.createClass as create-react-class, React.PropTypes as prop-types, React.DOM as react-dom-factories, changes to the behavior of scheduling and lifecycle methods.
|-
|16.1.0
|9 November 2017
|Discontinuing Bower Releases, Fix an accidental extra global variable in the UMD builds, Fix onMouseEnter and onMouseLeave firing, Fix <textarea> placeholder, Remove unused code, Add a missing package.json dependency, Add support for React DevTools.
|-
|16.3.0
|29 March 2018
|Add a new officially supported context API, Add new packagePrevent an infinite loop when attempting to render portals with SSR, Fix an issue with this.state, Fix an IE/Edge issue.
|-
|16.3.1
|3 April 2018
|Prefix private API, Fix performance regression and error handling bugs in development mode, Add peer dependency, Fix a false positive warning in IE11 when using Fragment.
|-
|16.3.2
|16 April 2018
|Fix an IE crash, Fix labels in User Timing measurements, Add a UMD build, Improve performance of unstable_observedBits API with nesting.
|-
|16.4.0
|24 May 2018
|Add support for Pointer Events specification, Add the ability to specify propTypes, Fix reading context, Fix the getDerivedStateFromProps() support, Fix a testInstance.parent crash, Add React.unstable_Profiler component for measuring performance, Change internal event names.
|-
|16.5.0
|5 September 2018
|Add support for React DevTools Profiler, Handle errors in more edge cases gracefully, Add react-dom/profiling, Add onAuxClick event for browsers, Add movementX and movementY fields to mouse events, Add tangentialPressure and twist fields to pointer event.
|-
|16.6.0
|23 October 2018
|Add support for contextType, Support priority levels, continuations, and wrapped callbacks, Improve the fallback mechanism, Fix gray overlay on iOS Safari, Add React.lazy() for code splitting components.
|-
|16.7.0
|20 December 2018
|Fix performance of React.lazy for lazily-loaded components, Clear fields on unmount to avoid memory leaks, Fix bug with SSR, Fix a performance regression.
|-
|16.8.0
|6 February 2019
|Add Hooks, Add ReactTestRenderer.act() and ReactTestUtils.act() for batching updates, Support synchronous thenables passed to React.lazy(), Improve useReducer Hook lazy initialization API.
|-
|16.8.6
|27 March 2019
|Fix an incorrect bailout in useReducer(), Fix iframe warnings in Safari DevTools, Warn if contextType is set to Context.Consumer instead of Context, Warn if contextType is set to invalid values.
|-
|16.9.0
|9 August 2019
|Add <React.Profiler> API for gathering performance measurements programmatically. Remove unstable_ConcurrentMode in favor of unstable_createRoot
|-
|16.10.0
|27 September 2019
|Fix edge case where a hook update wasn't being memoized. Fix heuristic for determining when to hydrate, so we don't incorrectly hydrate during an update. Clear additional fiber fields during unmount to save memory. Fix bug with required text fields in Firefox. Prefer Object.is instead of inline polyfill, when available. Fix bug when mixing Suspense and error handling.
|-
|16.10.1
|28 September 2019
|Fix regression in Next.js apps by allowing Suspense mismatch during hydration to silently proceed
|-
|16.10.2
|3 October 2019
|Fix regression in react-native-web by restoring order of arguments in event plugin extractors
|-
|16.11.0
|22 October 2019
|Fix mouseenter handlers from firing twice inside nested React containers. Remove unstable_createRoot and unstable_createSyncRoot experimental APIs. (These are available in the Experimental channel as createRoot and createSyncRoot.)
|-
|16.12.0
|14 November 2019
|React DOM - Fix passive effects (<code>useEffect</code>) not being fired in a multi-root app.
 
React Is - Fix <code>lazy</code> and <code>memo</code> types considered elements instead of components
|-
|16.13.0
|26 February 2020
|Features added in React Concurrent mode.
Fix regressions in React core library and React Dom.
|
|-
|16.13.1
|19 March 2020
|Fix bug in legacy mode Suspense.
Revert warning for cross-component updates that happen inside class render lifecycles
|
|-
|16.14.0
|14 October 2020
|Add support for the new JSX transform.
|
|-
|17.0.0
|20 October 2020
|"No New Features" enables gradual React updates from older versions.
Add new JSX Transform, Changes to Event Delegation
|
|-
|17.0.1
|22 October 2020
|React DOM - Fixes a crash in IE11
|}
 
==Licensing==
The initial public release of React in May 2013 used the [[Apache License 2.0]]. In October 2014, React 0.12.0 replaced this with the [[BSD licenses#3-clause|3-clause BSD license]] and added a separate PATENTS text file that permits usage of any Facebook patents related to the software:<ref>{{cite web|title=React CHANGELOG.md|url=https://github.com/facebook/react/blob/master/CHANGELOG.md#0120-october-28-2014|website=GitHub}}</ref><blockquote>The license granted hereunder will terminate, automatically and without notice, for anyone that makes any claim (including by filing any lawsuit, assertion or other action) alleging (a) direct, indirect, or contributory infringement or inducement to infringe any patent: (i) by Facebook or any of its subsidiaries or affiliates, whether or not such claim is related to the Software, (ii) by any party if such claim arises in whole or in part from any software, product or service of Facebook or any of its subsidiaries or affiliates, whether or not such claim is related to the Software, or (iii) by any party relating to the Software; or (b) that any right in any patent claim of Facebook is invalid or unenforceable.</blockquote>This unconventional clause caused some controversy and debate in the React user community, because it could be interpreted to empower Facebook to revoke the license in many scenarios, for example, if Facebook sues the licensee prompting them to take "other action" by publishing the action on a blog or elsewhere. Many expressed concerns that Facebook could unfairly exploit the termination clause or that integrating React into a product might complicate a startup company's future acquisition.<ref>{{cite web|title=A compelling reason not to use ReactJS|first=Austin|last=Liu|url=https://medium.com/bits-and-pixels/a-compelling-reason-not-to-use-reactjs-beac24402f7b|website=Medium}}</ref>
 
Based on community feedback, Facebook updated the patent grant in April 2015 to be less ambiguous and more permissive:<ref>{{cite web|title=Updating Our Open Source Patent Grant|url=https://code.facebook.com/posts/1639473982937255/updating-our-open-source-patent-grant/}}</ref>
 
<blockquote>The license granted hereunder will terminate, automatically and without notice, if you (or any of your subsidiaries, corporate affiliates or agents) initiate directly or indirectly, or take a direct financial interest in, any Patent Assertion: (i) against Facebook or any of its subsidiaries or corporate affiliates, (ii) against any party if such Patent Assertion arises in whole or in part from any software, technology, product or service of Facebook or any of its subsidiaries or corporate affiliates, or (iii) against any party relating to the Software. [...] A "Patent Assertion" is any lawsuit or other action alleging direct, indirect, or contributory infringement or inducement to infringe any patent, including a cross-claim or counterclaim.<ref>{{cite web|title=Additional Grant of Patent Rights Version 2|url=https://github.com/facebook/react/blob/b8ba8c83f318b84e42933f6928f231dc0918f864/PATENTS|website=GitHub}}</ref></blockquote>
 
The [[Apache Software Foundation]] considered this licensing arrangement to be incompatible with its licensing policies, as it "passes along risk to downstream consumers of our software imbalanced in favor of the licensor, not the licensee, thereby violating our Apache legal policy of being a universal donor", and "are not a subset of those found in the [Apache License 2.0], and they cannot be sublicensed as [Apache License 2.0]".<ref>{{Cite web|url=https://www.apache.org/legal/resolved.html|title=ASF Legal Previously Asked Questions|publisher=Apache Software Foundation|language=en|access-date=2017-07-16}}</ref> In August 2017, Facebook dismissed the Apache Foundation's downstream concerns and refused to reconsider their license.<ref>{{Cite web|url=https://code.facebook.com/posts/112130496157735/explaining-react-s-license/|title=Explaining React's License|website=Facebook|access-date=2017-08-18|language=en}}</ref><ref>{{Cite web|url=https://github.com/facebook/react/issues/10191#issuecomment-323486580|title=Consider re-licensing to AL v2.0, as RocksDB has just done|website=Github|language=en|access-date=2017-08-18}}</ref> The following month, [[WordPress]] decided to switch its Gutenberg and Calypso projects away from React.<ref>{{Cite web|url= https://techcrunch.com/2017/09/15/wordpress-to-ditch-react-library-over-facebook-patent-clause-risk/|title= WordPress to ditch React library over Facebook patent clause risk |website=TechCrunch|language=en|access-date=2017-09-16}}</ref>
 
On September 23, 2017, Facebook announced that the following week, it would re-license Flow, [[Jest (JavaScript framework)|Jest]], React, and Immutable.js under a standard [[MIT License]]; the company stated that React was "the foundation of a broad ecosystem of open source software for the web", and that they did not want to "hold back forward progress for nontechnical reasons".<ref>{{Cite web|url= https://code.facebook.com/posts/300798627056246/relicensing-react-jest-flow-and-immutable-js/|title= Relicensing React, Jest, Flow, and Immutable.js |website=Facebook Code|language=en|date=2017-09-23}}</ref>
 
On September 26, 2017, React 16.0.0 was released with the MIT license.<ref>{{cite web |url=https://reactjs.org/blog/2017/09/26/react-v16.0.html#mit-licensed|title= React v16.0§MIT licensed |last=Clark |first=Andrew |date=September 26, 2017 |website=React Blog}}</ref> The MIT license change has also been backported to the 15.x release line with React 15.6.2.<ref>{{cite web |url=https://reactjs.org/blog/2017/09/25/react-v15.6.2.html |title=React v15.6.2 |last=Hunzaker |first=Nathan |date=September 25, 2017 |website=React Blog}}</ref>
 
==See also==
{{Portal|Free and open-source software}}
*[[React Native]]
*[[AngularJS]]
*[[Angular (application platform)|Angular]]
*[[Backbone.js]]
*[[Ember.js]]
*[[Svelte]]
*[[Vue.js]]
*[[Comparison of JavaScript libraries]]
*[[Web Components]]
 
==References==
{{Reflist|2}}
 
==External links==
* {{Official website}}
 
{{JS templating |state=autocollapse}}
{{Rich Internet applications}}
{{ECMAScript}}
{{Facebook navbox}}
 
[[Category:2015 software]]
[[Category:Ajax (programming)]]
[[Category:Facebook software]]
[[Category:JavaScript libraries]]
[[Category:Software using the MIT license]]
[[Category:Web applications]]