React (software): Difference between revisions

Content deleted Content added
Thunder491 (talk | contribs)
mNo edit summary
 
(785 intermediate revisions by more than 100 users not shown)
Line 1:
{{For|the open-source mobile application framework|React Native}}
 
{{Short description|JavaScript library for building user interfaces}}
{{Multiple issues|
{{More citations needed|date=May 2024}}
{{Self-published|date=May 2024}}
}}
{{Infobox software
| name = React
| logo = React-icon Logo SVG.svg
| logo size = 140px130px
| author = Jordan Walke
| developer = [[FacebookMeta Platforms|Meta]] and community
| released = {{Start date and age|2013|5|29}}<ref name="Occhino-2013">{{cite web|access-date=22 Oct 2018|first1=Tom|first2=Jordan|last1=Occhino|last2=Walke|title=JS Apps at Facebook|url=https://www.youtube.com/watch?v=GW0rj4sNH2w|website=YouTube|date=5 August 2013 |archive-date=31 May 2022|archive-url=https://web.archive.org/web/20220531133559/https://www.youtube.com/watch?v=GW0rj4sNH2w|url-status=live}}</ref><ref>{{Cite web |date=2021-04-12 |title=Is React a Library or a Framework? Here's Why it Matters |url=https://www.freecodecamp.org/news/is-react-a-library-or-a-framework/ |access-date=2024-10-12 |website=freeCodeCamp.org |language=en}}</ref>
| released = {{Start date and age|2013|3}}
| ver layout = stacked
| latest release version = 16.5.0
| latest release version = {{wikidata|property|reference|edit|P348}}
| latest release date = {{Start date and age|2018|9|6}}<ref name="ghrelease">{{cite web |url=https://github.com/facebook/react/releases |title=Releases – Facebook/React |website=[[GitHub]]}}</ref><!-- DO NOT CHANGE THIS REFERENCE: the GitHub release page can remain as a static reference for all foreseeable releases-->
| latest previewrelease versiondate = {{start date and age|
{{wikidata|qualifier|P348|P577}}
| latest preview date = <!-- {{Start date and age|2016|04|7}}<ref name="ghrelease"/> -->
}}
<!--| status = Active -->
| latest preview version = 19.0.0-rc.1
| latest preview date = {{Start date and age|2024|11|14}}<ref name="customelements">{{cite web|url=https://react.dev/blog/2024/04/25/react-19#whats-new-in-react-19|title=What's new in React 19|access-date=2024-05-12|archive-date=2024-05-12|archive-url=https://web.archive.org/web/20240512195006/https://react.dev/blog/2024/04/25/react-19#whats-new-in-react-19|url-status=live}}</ref>
| programming language = [[JavaScript]]
| platform = [[Cross-Web platform]]
| size = 109 KiB production<br />710 KiB development
| genre = [[JavaScript library]]
| license = [[MIT License]]
| website = {{URL|reactjshttps://react.org}}dev/
}}
 
In [[computing]], '''React''' (also known as '''React.js''' or '''ReactJS''') is a [[free and open-source software|free and open-source]] [[frontend and backend|front-end]] [[JavaScript library]]<ref name="reactreactjs.org-3">{{Cite web |title=React – A JavaScript library for building user interfaces. |url=https://reactjs.org |url-status=live |access-date=7 April 2018 |website=reactjs.org |language=en-US |archive-date=April 8, 2018 |archive-url=https://web.archive.org/web/20180408084010/https://reactjs.org/ }}</ref><ref>{{Cite web |title=Chapter 1. What Is React? - AWhat JavaScriptReact libraryIs forand buildingWhy userIt interfacesMatters [Book] |url=https://www.oreilly.com/library/view/what-react-is/9781491996744/ch01.html |websiteurl-status=Reactlive |access-date=72023-05-06 April|website=www.oreilly.com |language=en |archive-date=May 6, 2023 |archive-url=https://web.archive.org/web/20230506100446/https://www.oreilly.com/library/view/what-react-is/9781491996744/ch01.html 2018}}</ref> forthat aims to make building [[user interfacesinterface]]s based on [[component-based software engineering|components]] more "seamless".<ref name="reactjs.org-3" /> It is maintained by [[FacebookMeta Platforms|Meta]] (formerly Facebook) and a community of individual developers and companies.<ref>{{cite web |last=Krill |first=Paul |date=May 15, 2014 |title=React: Making faster, smoother UIs for data-driven Web apps |url=https://www.infoworld.com/article/2608181/javascript/react--making-faster--smoother-uis-for-data-driven-web-apps.html |titleaccess-date=React: Making faster, smoother UIs for data2021-driven Web apps02-23 |lastwebsite=Krill[[InfoWorld]] |firstarchive-date=Paul2018-06-12 |datearchive-url=May 15, 2014https://web.archive.org/web/20180612141516/https://www.infoworld.com/article/2608181/javascript/react--making-faster--smoother-uis-for-data-driven-web-apps.html |websiteurl-status=[[InfoWorld]]live }}</ref><ref>{{cite web |urllast=https://www.infoq.com/news/Hemel |first=Zef |date=June 3, 2013/06/facebook-react |title=Facebook's React JavaScript User Interfaces Library Receives Mixed Reviews |lasturl=Hemelhttps://www.infoq.com/news/2013/06/facebook-react |firsturl-status=Zeflive |access-date=June2022-01-11 3,|website=infoq.com |language=en-US |archive-url=https://web.archive.org/web/20220526082114/https://www.infoq.com/news/2013/06/facebook-react/ |websitearchive-date=InfoQMay 26, 2022}}</ref><ref>{{cite web |last=Dawson |first=Chris |date=July 25, 2014 |title=JavaScript's History and How it Led To ReactJS |url=https://thenewstack.io/javascripts-history-and-how-it-led-to-reactjs/ |titleurl-status=JavaScript’slive History|access-date=2020-07-19 and|website=The HowNew it Led To ReactJSStack |lastlanguage=Dawsonen-US |firstarchive-url=Chrishttps://web.archive.org/web/20200806190027/https://thenewstack.io/javascripts-history-and-how-it-led-to-reactjs/ |archive-date=JulyAug 256, 20142020 |website=The New Stack}}</ref>
 
React can be used to develop [[single-page application|single-page]], mobile, or [[server-side rendering|server-rendered]] applications with frameworks like [[Next.js]] and [[Remix (web framework)|Remix]]{{Efn|Merged into [[React Router]] since React Router v7<ref>{{Cite web |last=Lybrand |first=Brooks |date=2024-05-15 |title=Merging Remix and React Router |url=https://remix.run/blog/merging-remix-and-react-router |access-date=2024-12-25 |website=remix.run |language=en}}</ref>}}. Because React is only concerned with the user interface and rendering components to the [[Document Object Model|DOM]], React applications often rely on [[JavaScript libraries|libraries]] for routing and other client-side functionality.{{sfn|Dere|2017}}{{sfn|Panchal|2022}} A key advantage of React is that it only re-renders those parts of the page that have changed, avoiding unnecessary re-rendering of unchanged DOM elements.
React can be used as a base in the development of [[single-page application|single-page]] or mobile applications. Complex React applications usually require the use of additional libraries for [[state management]], [[Web_framework#URL_mapping|routing]], and interaction with an [[API]].<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>
 
== Notable features ==
==History==
=== Declarative ===
React was created by Jordan Walke, a software engineer at Facebook. He was influenced by [[XHP]], an [[HTML]] component framework for [[PHP]].<ref>{{cite web|title=React (JS Library): How was the idea to develop React conceived and how many people worked on developing it and implementing it at Facebook?|url=https://www.quora.com/React-JS-Library/How-was-the-idea-to-develop-React-conceived-and-how-many-people-worked-on-developing-it-and-implementing-it-at-Facebook/answer/Bill-Fisher-17|website=Quora}}</ref> It was first deployed on Facebook's newsfeed in 2011 and later on [[Instagram.com]] 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.
React adheres to the [[declarative programming]] [[Programming paradigm|paradigm]].<ref>{{Cite web |date=2017-09-27 |title=React Introduction |url=https://www.geeksforgeeks.org/reactjs-introduction/ |access-date=2024-10-12 |website=GeeksforGeeks |language=en-US}}</ref>{{sfn|Wieruch|2020}}{{rp|76}} Developers design views for each state of an application, and React updates and renders components when data changes. This is in contrast with [[imperative programming]].{{sfn|Schwarzmüller|2018}}
 
=== Components ===
[[#React Native|React Native]], which enables native [[Android (operating system)|Android]], [[iOS]], and [[Universal Windows Platform|UWP]] development with React, was announced at Facebook's React.js Conf in February 2015 and open-sourced in March 2015.
React code is made of entities called [[Component-based software engineering|components]].{{sfn|Wieruch|2020}}{{rp|10-12}} These components are modular and can be reused.{{sfn|Wieruch|2020}}{{rp|70}} React applications typically consist of many layers of components. The components are rendered to a root element in the [[Document Object Model|DOM]] using the React DOM library. When rendering a component, values are passed between components through ''props'' (short for "properties")''.'' Values internal to a component are called its ''state.''<ref>{{cite web |title=Components and Props |url=https://reactjs.org/docs/components-and-props.html#props-are-read-only |url-status=live |access-date=7 April 2018 |website=React |publisher=Facebook |archive-date=7 April 2018 |archive-url=https://web.archive.org/web/20180407120115/https://reactjs.org/docs/components-and-props.html}}</ref>
 
The two primary ways of declaring components in React are through function components and class components.{{sfn|Wieruch|2020}}{{rp|118}}{{sfn|Larsen|2021}}{{rp|10}} Since React v16.8, using function components is the recommended way.
On April 18, 2017, Facebook announced [[React Fiber]], a new core algorithm of React framework 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 framework|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 framework.<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}}
 
=== Function components ===
==Basic usage==
Function components, announced at React Conf 2018, and available since React v16.8, are declared with a function that accepts a single "props" argument and returns JSX. Function components can use internal state with the <code>useState</code> Hook.
The following is a rudimentary example of React usage in HTML with [[React_(JavaScript_library)#JSX|JSX]] and JavaScript.
<ref name="introducing_hooks"/>
<syntaxhighlight lang="html">
<div id="myReactApp"></div>
 
=== React Hooks ===
<script type="text/babel">
On February 16, 2019, React 16.8 was released to the public, introducing React Hooks.<ref name="introducing_hooks">{{cite web
class Greeter extends React.Component {
|url=https://reactjs.org/docs/hooks-intro.html
render() {
|title=Introducing Hooks
return <h1>{this.props.greeting}</h1>
|publisher=react.js
}
|access-date=2019-05-20
}
|archive-date=2018-10-25
|archive-url=https://web.archive.org/web/20181025163202/https://reactjs.org/docs/hooks-intro.html
|url-status=live
}}</ref> 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|archive-date=2023-03-15|archive-url=https://web.archive.org/web/20230315054047/https://reactjs.org/docs/hooks-overview.html|url-status=live}}</ref> Notably, Hooks do not work inside classes — they let developers use more features of React without classes.<ref>{{Cite web |date=2020-01-16 |title=What the Heck is React Hooks? |url=https://soshace.com/2020/01/16/what-the-heck-is-react-hooks/ |url-status=live |archive-url=https://web.archive.org/web/20220531133601/https://blog.soshace.com/what-the-heck-is-react-hooks/ |archive-date=2022-05-31 |access-date=2020-01-24 |website=Soshace |language=en}}</ref>
 
React provides several built-in hooks such as <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|archive-date=2022-07-30|archive-url=https://web.archive.org/web/20220730180312/https://reactjs.org/docs/hooks-state.html|url-status=live}}</ref>{{sfn|Larsen|2021}}{{rp|37}} <code>useContext</code>,{{sfn|Wieruch|2020}}{{rp|11}}<ref name="reactjs.org-2">{{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|archive-date=2022-07-30|archive-url=https://web.archive.org/web/20220730180312/https://reactjs.org/docs/hooks-state.html|url-status=live}}</ref>{{sfn|Larsen|2021}}{{rp|12}} <code>useReducer</code>,{{sfn|Wieruch|2020}}{{rp|92}}<ref name="reactjs.org-2" />{{sfn|Larsen|2021}}{{rp|65-66}} <code>useMemo</code>{{sfn|Wieruch|2020}}{{rp|154}}<ref name="reactjs.org-2" />{{sfn|Larsen|2021}}{{rp|162}} 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|archive-date=2022-08-01|archive-url=https://web.archive.org/web/20220801212858/https://reactjs.org/docs/hooks-effect.html|url-status=live}}</ref>{{sfn|Larsen|2021}}{{rp|93-95}} 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|archive-date=2022-08-05|archive-url=https://web.archive.org/web/20220805061010/https://reactjs.org/docs/hooks-reference.html|url-status=live}}</ref>{{sfn|Wieruch|2020}}{{rp|62}} <code>useState</code> and <code>useEffect</code>, which are the most commonly used, are for controlling [[State (computer science)|state]]{{sfn|Wieruch|2020}}{{rp|37}} and [[Side effect (computer science)|side effects]],{{sfn|Wieruch|2020}}{{rp|61}} respectively.
ReactDOM.render(<Greeter greeting="Hello World!" />, document.getElementById('myReactApp'));
 
</script>
==== Rules of hooks ====
</syntaxhighlight>
There are two 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|archive-date=2021-06-06|archive-url=https://web.archive.org/web/20210606174151/https://reactjs.org/docs/hooks-rules.html|url-status=live}}</ref> which describe the characteristic code patterns that hooks rely on:
The <code>Greeter</code> class is a React component that accepts a property <code>greeting</code>. The <code>ReactDOM.render</code> method creates an instance of the <code>Greeter</code> component, sets the <code>greeting</code> property to <code>'Hello World'</code> and inserts the rendered component as a child element to the DOM element with id <code>myReactApp</code>.
 
# "Only call hooks at the top level" — do not call hooks from inside loops, conditions, or nested statements so that the hooks are called in the same order each render.
# "Only call hooks from React functions" — do not call hooks from plain JavaScript functions so that stateful logic stays with the component.
 
Although these rules cannot be enforced at runtime, code analysis tools such as [[Lint (software)|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|archive-date=2022-07-17|archive-url=https://web.archive.org/web/20220717175155/https://reactjs.org/docs/hooks-custom.html|url-status=live}}</ref> which may call other Hooks.
 
=== Server components ===
When displayed in a web browser the result will be
React server components (RSC) <ref>{{Cite web|url=https://react.dev/blog/2023/03/22/react-labs-what-we-have-been-working-on-march-2023#react-server-components|title=React Labs: What We've Been Working On – March 2023|website=react.dev|language=en|access-date=2023-07-23|archive-date=2023-07-26|archive-url=https://web.archive.org/web/20230726201006/https://react.dev/blog/2023/03/22/react-labs-what-we-have-been-working-on-march-2023#react-server-components|url-status=live}}</ref> are function components that run exclusively on the server. The concept was first introduced in the talk "Data Fetching with Server Components".<ref>{{Cite web |last1=Abramov |first1=Dan |last2=Tan |first2=Lauren |last3=Savona |first3=Joseph |last4=Markbåge |first4=Sebastian |date=2020-12-21 |title=Introducing Zero-Bundle-Size React Server Components |url=https://react.dev/blog/2020/12/21/data-fetching-with-react-server-components |access-date=2024-09-28 |website=react.dev |language=en}}</ref> Though a similar concept to Server Side Rendering, RSCs do not send corresponding JavaScript to the client as no hydration occurs. As a result, they have no access to hooks. However, they may be [[Async/await|asynchronous function]], allowing them to directly perform asynchronous operations:
<syntaxhighlight lang="html">
 
<div id="myReactApp">
<syntaxhighlight lang="jsx" line="1">
<h1>Hello World!</h1>
async function MyComponent() {
</div>
const message = await fetchMessageFromDb();
 
return (
<div>Message: {message}</div>
);
}
</syntaxhighlight>
 
Currently, server components are most readily usable with [[Next.js]]. With Next.js, it's possible to write components for both the server and the client (browser). When a server rendered component is received by the browser, React in the browser takes over and creates the virtual DOM and attach event handlers. This is called hydration.
==Notable features==
<ref>{{Cite web |title= hydrate |url=https://18.react.dev/reference/react-dom/hydrate#hydrating-server-rendered-html |access-date=2025-06-19 |language=en |archive-url=https://web.archive.org/web/20240716002720/https://18.react.dev/reference/react-dom/hydrate#hydrating-server-rendered-html |archive-date=2024-07-16 |url-status=live }}</ref>
===One-way data binding with props===
Properties (commonly, ''props'') are passed to a component from the parent component. Components receive props as a single set of immutable values<ref>{{cite web|url=https://reactjs.org/docs/components-and-props.html#props-are-read-only|website=React|title=Components and Props|publisher=Facebook|accessdate=7 April 2018}}</ref> (a JavaScript object).
 
=== StatefulClass components ===
Class components are declared using [[ECMAScript|ES6]] classes. They behave the same way that function components do, but instead of using Hooks to manage state and lifecycle events, they use the lifecycle methods on the <code>React.Component</code> [[Inheritance (object-oriented programming)|base class]].
States hold values throughout the component and can be passed to child components through props:
<syntaxhighlight lang="jsjsx" line="1">
class ParentComponent extends React.Component {
state = { color: 'redgreen' };
render() {
return (
Line 69 ⟶ 92:
}
}
</syntaxhighlight>The introduction of React Hooks with React 16.8 in February 2019 allowed developers to manage state and lifecycle behaviors within functional components, reducing the reliance on class components.
</syntaxhighlight>
 
This trend aligns with the broader industry movement towards functional programming and modular design. As React continues to evolve, it is essential for developers to consider the benefits of functional components and React Hooks when building new applications or refactoring existing ones.<ref>{{Cite web |last=Chourasia |first=Rawnak |date=2023-03-08 |title=Convert Class Component to Function(Arrow) Component – React |url=https://codeparttime.com/convert-class-to-function-arrow-react/ |access-date=2023-08-15 |website=Code Part Time |archive-date=2023-08-15 |archive-url=https://web.archive.org/web/20230815131020/https://codeparttime.com/convert-class-to-function-arrow-react/ |url-status=live }}</ref>
===Virtual DOM===
Another notable feature is the use of a "virtual [[Document Object Model]]", or "virtual DOM". React creates an 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 allows the programmer to write code as if the entire page is rendered on each change, while the React libraries only render sub components that actually change.
 
=== Lifecycle methodsRouting ===
React itself does not come with built-in support for [[routing]]. React is primarily a library for building user interfaces, and it does not include a full-fledged routing solution out of the box. Third-party libraries can be used to handle routing in React applications.<ref>{{Cite web |date=2023-07-12 |title=Mastering React Router – The Ultimate Guide |url=https://www.devban.com/react-router-ultimate-guide/ |access-date=2023-07-26 |language=en-US |archive-date=2023-07-26 |archive-url=https://web.archive.org/web/20230726063450/https://www.devban.com/react-router-ultimate-guide/ |url-status=live }}</ref> It allows the developer to define routes, manage navigation, and handle URL changes in a React-friendly way.
Lifecycle methods are [[Hooking|hooks]] which allow execution of code at set points during the component's lifetime.
 
[[File:VirtualDOM with respect to realDOM.png|thumb|There is a Virtual DOM that is used to implement the real DOM]]
* <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>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, reflecting changes in the user interface.
 
===JSX 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, similar to the browser DOM. Every time components are rendered, the result is compared with the virtual DOM. It then updates the browser's displayed DOM efficiently with only the computed differences.<ref name="React Blog">{{cite web |title=Refs and the DOM |url=https://reactjs.org/docs/refs-and-the-dom.html |access-date=2021-07-19 |website=React Blog |archive-date=2022-08-07 |archive-url=https://web.archive.org/web/20220807171328/https://reactjs.org/docs/refs-and-the-dom.html |url-status=live }}</ref> This process is called '''reconciliation'''. This allows the programmer to write code as if the entire page is rendered on each change, while React only renders the components that actually change. This selective rendering provides a major performance boost.<ref name="Codecademy">{{Cite web |title=React: The Virtual DOM |url=https://www.codecademy.com/articles/react-virtual-dom |access-date=2021-10-14 |website=Codecademy |language=en |archive-date=2021-10-28 |archive-url=https://web.archive.org/web/20211028172953/https://www.codecademy.com/articles/react-virtual-dom |url-status=live }}</ref><ref name="Aggarwal">{{cite web |last1=Aggarwal |first1=Sanchit |title=Modern Web-Development using ReactJS |url=https://ijrra.net/Vol5issue1/IJRRA-05-01-27.pdf |website=International Journal of Recent Research Aspects |access-date=11 December 2024 |archive-url=https://web.archive.org/web/20240417143754/https://ijrra.net/Vol5issue1/IJRRA-05-01-27.pdf |archive-date=17 April 2024 |pages=133–137 |date=March 2018 |url-status=live}}</ref>
JSX (JavaScript eXtension) 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|accessdate=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, [[XHP]].
 
==== Updates ====
An example of JSX code:
When <code>ReactDOM.render</code><ref>{{Cite web |title=ReactDOM – React |url=https://reactjs.org/docs/react-dom.html |access-date=2023-01-08 |website=reactjs.org |language=en |archive-date=2023-01-08 |archive-url=https://web.archive.org/web/20230108104936/https://reactjs.org/docs/react-dom.html |url-status=live }}</ref> is called again for the same component and target, React represents the new UI state in the Virtual DOM and determines which parts (if any) of the living DOM needs to change.<ref>{{Cite web |title=Reconciliation – React |url=https://reactjs.org/docs/reconciliation.html |access-date=2023-01-08 |website=reactjs.org |language=en |archive-date=2023-01-08 |archive-url=https://web.archive.org/web/20230108105122/https://reactjs.org/docs/reconciliation.html |url-status=live }}</ref>
<syntaxhighlight lang="js">
class App extends React.Component {
render() {
return (
<div>
<p>Header</p>
<p>Content</p>
<p>Footer</p>
</div>
);
}
}
</syntaxhighlight>
 
[[File:React-example-virtual-dom-diff.svg|alt=Updates to realDOM are subject to virtualDOM|thumb|The virtualDOM will update the realDOM in real-time effortlessly]]
;Nested elements
Multiple elements on the same level need to be wrapped in a single container element such as the <code><nowiki><div></nowiki></code> element shown above, 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>.
 
=== Lifecycle methods ===
;Attributes
Lifecycle methods for class-based components use a form of [[hooking]] that allows the execution of code at set points during a component's lifetime.
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.
* <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>componentDidUpdate</code> is invoked immediately after updating occurs.<ref>{{Cite web |title=React.Component – React |url=https://legacy.reactjs.org/docs/react-component.html |access-date=2024-04-09 |website=legacy.reactjs.org |language=en |archive-date=2024-04-09 |archive-url=https://web.archive.org/web/20240409075058/https://legacy.reactjs.org/docs/react-component.html |url-status=live }}</ref>
* <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 ===
;JavaScript expressions
{{Main|JSX (JavaScript)|l1=JSX}}
JavaScript expressions (but not statements) can be used inside JSX with curly brackets <code>{}</code>:
[[JSX (JavaScript)|JSX]], or JavaScript XML, is an extension to the JavaScript language syntax.<ref>{{cite web |date=2022-03-08 |title=Draft: JSX Specification |url=https://facebook.github.io/jsx/ |access-date=7 April 2018 |website=JSX |publisher=Facebook |language=en-US |archive-date=2022-04-02 |archive-url=https://web.archive.org/web/20220402072504/https://facebook.github.io/jsx/ |url-status=live }}</ref> Similar in appearance to HTML,{{sfn|Wieruch|2020}}{{rp|11}} JSX provides a way to structure component rendering using syntax familiar{{sfn|Wieruch|2020}}{{rp|15}} 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). During compilation, JSX is converted to JavaScript code. JSX is similar to another extension syntax created by Facebook for [[PHP]] called [[XHP]].
<syntaxhighlight lang="js">
<h1>{10+1}</h1>
</syntaxhighlight>
 
TheAn example aboveof will renderJSX code:
<syntaxhighlight lang="htmljsx">
function Example() {
<h1>11</h1>
// Declare a new state variable, which we'll call "count"
</syntaxhighlight>
const [count, setCount] = useState(0);
 
return (
;Conditional statements
<div>
[[Conditional (computer programming)|If–else statements]] cannot be used inside JSX but conditional expressions can be used instead.
<p>You clicked {count} times</p>
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.
<button onClick={() => setCount(count + 1)}>
<syntaxhighlight lang="js">
Click me
class App extends React.Component {
</button>
render() {
const i = 1;</div>
);
return (
<div>
<h1>{ i === 1 ? 'true' : 'false' }</h1>
</div>
);
}
}
</syntaxhighlight>
Functions and JSX can be used in conditionals:
<syntaxhighlight lang="js">
class App extends React.Component {
render() {
const sections = [1, 2, 3];
return (
<div>
{
sections.length > 0
? sections.map(n => <div>Section {n}</div>)
: null
}
</div>
);
}
}
</syntaxhighlight>
The above will render:
<syntaxhighlight lang="html">
<div>
<div>Section 1</div>
<div>Section 2</div>
<div>Section 3</div>
</div>
</syntaxhighlight>
 
=== Architecture beyond HTML ===
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]].
The basic [[Software architecture|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 |last=Hunt |first=Pete |date=2013-06-05 |title=Why did we build React? – React Blog |url=https://facebook.github.io/react/blog/2013/06/05/why-react.html |access-date=2022-02-17 |website=reactjs.org |language=en-US |archive-date=2015-04-06 |archive-url=https://web.archive.org/web/20150406072833/http://facebook.github.io/react/blog/2013/06/05/why-react.html |url-status=dead }}</ref> and Netflix and [[PayPal]] use universal loading to render identical HTML on both the server and client.<ref name="medium.com-2015">{{cite web |date=2015-04-27 |title=PayPal Isomorphic React |url=https://medium.com/paypal-engineering/isomorphic-react-apps-with-react-engine-17dae662379c |url-status=live |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 |access-date=2019-02-08 |website=medium.com}}</ref><ref name="netflixtechblog.com-2015">{{cite web |date=2015-01-28 |title=Netflix Isomorphic React |url=http://techblog.netflix.com/2015/01/netflix-likes-react.html |access-date=2022-02-14 |website=netflixtechblog.com |language=en-US |archive-date=2016-12-17 |archive-url=https://web.archive.org/web/20161217043150/http://techblog.netflix.com/2015/01/netflix-likes-react.html |url-status=live }}</ref> React can also be used to develop native apps for Android and iOS using [[React Native]].
 
=== Server-side rendering ===
===Architecture beyond HTML===
[[Server-side scripting|Server-side rendering]] (SSR) refers to the process of rendering a client-side JavaScript application on the server, rather than in the browser.<ref name="MDNSSR">
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|publisher=}}</ref> and Netflix and [[PayPal]] use isomorphic loading to render identical HTML on both the server and client.<ref name=paypal-isomorphic-reactjs>{{cite web|title=PayPal Isomorphic React|url=https://www.paypal-engineering.com/2015/04/27/isomorphic-react-apps-with-react-engine/}}</ref><ref name=netflix-isomorphic-reactjs>{{cite web|title=Netflix Isomorphic React|url=http://techblog.netflix.com/2015/01/netflix-likes-react.html}}</ref>
{{cite web
|title=Server-side rendering (SSR) - MDN Web Docs Glossary
|url=https://developer.mozilla.org/en-US/docs/Glossary/SSR
|website=MDN Web Docs
|publisher=Mozilla
|access-date=7 March 2025
}}
</ref> This can improve the performance of the application, especially for users on slower connections or devices.<ref name="GoogleRendering">
{{cite web
|title=Rendering on the Web
|url=https://web.dev/rendering-on-the-web/
|website=web.dev
|publisher=Google
|date=6 February 2019
|access-date=7 March 2025
}}
</ref>
 
With SSR, the initial HTML that is sent to the client includes the fully rendered UI of the application.<ref name="CSS-Tricks-SSR">
==Common idioms==
{{cite web
React does not attempt to provide a complete 'application framework'. 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.
|last=Jain
|first=Atishay
|title=Render Caching for React
|url=https://css-tricks.com/render-caching-for-react/
|website=CSS-Tricks
|date=10 November 2018
|access-date=7 March 2025
}}
</ref> This allows the client's browser to display the UI immediately, rather than having to wait for the JavaScript to download and execute before rendering the UI.<ref name="CSS-Tricks-SSR" />
 
React supports SSR, which allows developers to render React components on the server and send the resulting HTML to the client.<ref name="ReactDoc">
===Use of the Flux architecture===
{{cite web
To support React's concept of unidirectional data flow (which might be contrasted with [[AngularJS|Angular'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|accessdate=7 April 2018|website=Flux}}</ref>. When used with React, this propagation is accomplished through component properties.
|title=Server React DOM APIs
|url=https://react.dev/reference/react-dom/server
|website=React Documentation
|publisher=Meta Platforms
|access-date=7 March 2025
}}
</ref> This can be useful for improving the performance of the application, as well as for [[search engine optimization]] purposes.<ref name="NextDocs">
{{cite web
|title=Rendering (Next.js Documentation)
|url=https://nextjs.org/docs/pages/building-your-application/rendering
|website=Next.js Documentation
|publisher=Vercel
|access-date=7 March 2025
}}
</ref>
 
== Common idioms ==
Flux can be considered a variant of the [[Observer_pattern|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|accessdate=7 April 2018}}</ref>.
React does not attempt to provide a complete application library. It is designed specifically for building user interfaces<ref name="reactjs.org-3" /> 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.
 
=== Unidirectional data flow ===
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|accessdate=7 April 2018}}</ref>. The stores (which can be thought of as models) can alter themselves in response to actions received from the dispatcher.
{{Main|Unidirectional data flow}}
To support React's concept of unidirectional data flow (which might be contrasted with [[AngularJS]]'s bidirectional flow), the ''Flux'' architecture was developed as 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|title=In Depth OverView|publisher=Facebook|access-date=7 April 2018|website=Flux|archive-date=7 August 2022|archive-url=https://web.archive.org/web/20220807201252/https://facebook.github.io/flux/docs/in-depth-overview/|url-status=dead}}</ref> When used with React, this propagation is accomplished through component properties. Since its conception, Flux has been superseded by libraries such as [[Redux (JavaScript library)|Redux]] and MobX.<ref>{{cite web|title=Flux Release 4.0|url=https://github.com/facebook/flux/releases/tag/4.0.0|website=Github|access-date=26 February 2021|archive-date=31 May 2022|archive-url=https://web.archive.org/web/20220531133558/https://github.com/facebook/flux/releases/tag/4.0.0|url-status=live}}</ref>
 
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|archive-date=31 May 2022|archive-url=https://web.archive.org/web/20220531133600/http://nicholasjohnson.com/react/course/exercises/flux/|url-status=live}}</ref>
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|accessdate=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 function]]s 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|archive-date=19 April 2018|archive-url=https://web.archive.org/web/20180419075905/http://threedevsandamaybe.com/the-history-of-react-and-flux-with-dan-abramov/|url-status=live}}</ref> The stores, which can be thought of as models, can alter themselves in response to actions received from the dispatcher.
==React Native==
React Native was announced by Facebook in 2015,<ref name="initial_rn_post">{{cite web|url=https://code.facebook.com/posts/1014532261909640/react-native-bringing-modern-web-techniques-to-mobile/|title=React Native: Bringing modern web techniques to mobile|publisher=}}</ref> applying the React architecture to native [[Android (operating system)|Android]]<ref>{{cite web|url=https://code.facebook.com/posts/1189117404435352/react-native-for-android-how-we-built-the-first-cross-platform-react-native-app/|title=Android Release for React Native}}</ref>, [[iOS]], and [[Universal Windows Platform|UWP]]<ref>{{cite web |author=Windows Apps Team |date=April 13, 2016 |title=React Native on the Universal Windows Platform |url=https://blogs.windows.com/buildingapps/2016/04/13/react-native-on-the-universal-windows-platform/ |website=blogs.windows.com |accessdate=2016-11-06}}</ref> applications.
 
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=http://2016.stateofjs.com/2016/statemanagement/|website=The State of JavaScript|access-date=29 October 2021|archive-date=31 May 2022|archive-url=https://web.archive.org/web/20220531133609/http://2016.stateofjs.com/2016/statemanagement/|url-status=live}}</ref>
===History===
 
In February 2019, <code>useReducer</code> was introduced as a [[#React Hooks|React hook]] in the 16.8 release. It provides an API that is consistent with Redux, enabling developers to create Redux-like stores that are local to component states.<ref>{{Cite web |url=https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#react-1 |title=React v16.8: The One with Hooks |access-date=2023-01-08 |archive-date=2023-01-08 |archive-url=https://web.archive.org/web/20230108090021/https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#react-1 |url-status=live }}</ref>
In 2012 [[Mark Zuckerberg]] commented, "The biggest mistake we made as a company was betting too much on HTML5 as opposed to native".<ref>{{cite web|title=Zuckerberg's Biggest Mistake? 'Betting on HTML5'|url=https://mashable.com/2012/09/11/html5-biggest-mistake|publisher=Mashable|accessdate=7 April 2018}}</ref> He promised that [[Facebook]] would soon deliver a better mobile experience.
 
== History ==
Inside [[Facebook]], Jordan Walke found a way to generate [[iOS]] [[User_interface|UI]] elements from a background [[JavaScript]] [[Thread_(computing)|thread]]. They decided to organize an internal [[hackathon]] to perfect this [[prototype]] in order to be able to build[[Mobile_app| native apps]] with this technology.<ref>{{cite web|title=A short Story about React Native|url=https://jobninja.com/blog/short-story-react-native/|accessdate=16 January 2018}}</ref>
React was created by Jordan Walke, a software engineer at [[Meta Platforms|Meta]], who initially developed a prototype called "F-Bolt"<ref name="Youtube-2023">{{cite web |title=React.js: The Documentary |url=https://youtube.com/watch?v=8pDqJVdNa44%3Fsi%3DFMJqegC4dPtwKP__&t=528 |website=Youtube | date=10 February 2023 |publisher=Honeypot |access-date=2024-05-27 |archive-date=2024-01-19 |archive-url=https://web.archive.org/web/20240119211307/https://www.youtube.com/watch?v=8pDqJVdNa44%3Fsi%3DFMJqegC4dPtwKP__&t=528 |url-status=live }}</ref> before later renaming it to "FaxJS". This early version is documented in Jordan Walke's GitHub repository.{{ref|Walke, Jordan. "FaxJS." GitHub. https://github.com/jordwalke/FaxJs. Accessed 11 July 2019.}} Influences for the project included [[XHP]], an [[HTML]] component library for [[PHP]].
 
React was first deployed on Facebook's [[News Feed]] in 2011 and subsequently integrated into [[Instagram]] in 2012.<ref name="Lopez">{{cite web |last1=Lopez |first1=Marny |title=Why React is so widely adopted by web developers? |url=https://www.devlane.com/blog/why-react-is-so-widely-adopted-by-web-developers |website=Devlane |access-date=11 December 2024 |archive-url=https://web.archive.org/web/20240620092857/https://www.devlane.com/blog/why-react-is-so-widely-adopted-by-web-developers |archive-date=20 June 2024 |date=13 May 2024 |url-status=live}}</ref> In May 2013, at JSConf US, the project was officially open-sourced, marking a significant turning point in its adoption and growth.{{ref|Hámori, Emergent. "React – The Pragmatic Guide." 2022.}}
After a few months of development, [[Facebook]] released the first version for the React.js Conf 2015. During a technical talk,<ref>{{cite web|last1=Christopher|first1=Chedeau|title=A Deep Dive into React Native|url=https://www.youtube.com/watch?v=7rDsRXj9-cU|website=YouTube|accessdate=16 January 2018}}</ref> Christopher Chedeau explained that [[Facebook]] was already using React Native in production for their Group App and their Ads Manager App.<ref name="initial_rn_post" />
 
[[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.
===Working principles===
 
On April 18, 2017, Facebook announced React Fiber, a new set of internal algorithms for rendering, as opposed to React's old rendering algorithm, Stack.{{sfn|Lardinois|2017}} 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|archive-date = 10 May 2018|archive-url = https://web.archive.org/web/20180510140634/https://github.com/acdlite/react-fiber-architecture|url-status = live}}</ref>{{Update inline|reason=Last commit was in 2016. Is this statement still true?|date=June 2018}} The actual syntax for programming with React does not change; only the way that the syntax is executed has changed.<ref name="TechCrunch-2017">{{cite web|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 framework|website=TechCrunch|date=18 April 2017 |accessdate=2018-10-19|archive-date=2018-06-14|archive-url=https://web.archive.org/web/20180614172053/https://techcrunch.com/2017/04/18/facebook-announces-react-fiber-a-rewrite-of-its-react-framework/|url-status=live}}</ref> React's old rendering system, Stack, was developed at a time when the focus of the system on dynamic change was not understood. Stack was slow to draw complex animation, for example, trying to accomplish all of it in one chunk. Fiber breaks down animation into segments that can be spread out over multiple frames. Likewise, the structure of a page can be broken into segments that may be maintained and updated separately. JavaScript functions and virtual [[Document Object Model|DOM]] objects are called "fibers", and each can be operated and updated separately, allowing for smoother on-screen rendering.<ref name="github.com">{{cite web|url=https://github.com/acdlite/react-fiber-architecture|title=GitHub – acdlite/react-fiber-architecture: A description of React's new core algorithm, React Fiber|website=github.com|accessdate=2018-10-19|archive-date=2018-05-10|archive-url=https://web.archive.org/web/20180510140634/https://github.com/acdlite/react-fiber-architecture|url-status=live}}</ref>
The working principles of React Native are basically the same as React except that it is not manipulating the [[Document_Object_Model|DOM]] via the [[React_(JavaScript_library)#Virtual_DOM|VirtualDom]] but some native views. It runs in a [[background process]] (which interprets the [[JavaScript]] written by the developers) directly on the end-device and communicates with the native platform via a [[Serialization|serializable]], [[Asynchrony_(computer_programming)|asynchronous]] and [[Batch_processing| batched]] Bridge<ref>{{cite web|title=Bridging in React Native|url=https://tadeuzagallo.com/blog/react-native-bridge/|accessdate=16 January 2018|date=14 October 2015}}</ref>.<ref>{{cite web| url= https://parsed.io/react-native-vs-flutter/| title= React Native Framework }} Thursday, 13 September 2018 </ref>
 
On September 26, 2017, React 16.0 was released to the public.<ref>{{cite web
It can be seen that [[Facebook]] corrected the error that [[Mark Zuckerberg]] mentioned in 2012:{{or|date=March 2018}} React Native doesn't rely on HTML5 at all, everything is written in JavaScript, and relies on native SDKs.
|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
|archive-date=2017-10-03
|archive-url=https://web.archive.org/web/20171003031315/https://reactjs.org/blog/2017/09/26/react-v16.0.html
|url-status=live
}}</ref>
 
On October 20, 2020, the React team released 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 {{Webarchive|url=https://web.archive.org/web/20200810215037/https://reactjs.org/blog/2020/08/10/react-v17-rc.html |date=2020-08-10 }}</ref>
===Hello World===
 
On March 29, 2022, React 18 was released which introduced a new concurrent renderer, automatic batching and support for server side rendering with Suspense.<ref>{{cite web |title=React 18 |url=https://react.dev/blog/2022/03/29/react-v18 |website=React |access-date=7 December 2024}}</ref>
A [["Hello,_World!"_program| Hello, World]] program in React Native looks like this:
 
On December 5, 2024, React 19 was released. This release introduced Actions, which simplify the process of making state updates using asynchronous functions rather than having to manually handle pending states, errors and optimistic updates. React 19 also included support for server components and improved static site generation.<ref>{{cite web |title=React 19 |url=https://react.dev/blog/2024/12/05/react-19#whats-new-in-react-19 |website=React |access-date=7 December 2024}}</ref>
<syntaxhighlight lang="js" line="1">
import React, { Component } from 'react';
import { AppRegistry, Text } from 'react-native';
 
{| class="wikitable mw-collapsible mw-collapsed"
export default class HelloWorldApp extends Component {
|+ class="nowrap" | Version history of react
render() {
|-
return (
!Version
<Text>Hello world!</Text>
! width="150px" | Release Date
);
!Changes
}
|-
}
|0.3.0
|29 May 2013
|Initial Public Release
|-
|0.4.0
|20 July 2013
|Support for comment nodes {{tag|div|content={{mset|/* */}}}}, 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 {{tag|audio|o}} & {{tag|video|o}}, 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 {{tag|img|o}} elements.
|-
|0.10.0
|21 March 2014
|Added support for srcSet and textAnchor attributes, add update function for immutable data, Ensure all void elements do not 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.
|-
|15.0.0
|7 April 2016
|Initial render now uses document.createElement instead of generating HTML, No more extra {{tag|span|o}}s, Improved SVG support, {{code|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.
|-
|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 {{tag|link|o}} and onError handling to {{tag|source|o}} element, Add {{code|isRunning()}} API, Fix performance regression.
|-
|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.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 {{code|ReactTestRenderer.create()}}.
|-
|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.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.4.0
|24 May 2018
|Add support for Pointer Events specification, Add the ability to specify propTypes, Fix reading context, Fix the {{code|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 {{code|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 {{code|ReactTestRenderer.act()}} and {{code|ReactTestUtils.act()}} for batching updates, Support synchronous thenables passed to React.lazy(), Improve useReducer Hook lazy initialization API.
|-
|16.9.0
|9 August 2019
|Add {{mono|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 was not being memoized. Fix heuristic for determining when to hydrate, so we do not 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.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.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
|-
|18.0.0
|29 March 2022
|Concurrent React, Automatic batching, New Suspense Features, Transitions, Client and Server Rendering APIs, New Strict Mode Behaviors, New Hooks <ref name="reactjs.org">{{cite web|title=React v18.0|url=https://reactjs.org/blog/2022/03/29/react-v18.html|website=reactjs.org|language=en|access-date=2022-04-12|archive-date=2022-03-29|archive-url=https://web.archive.org/web/20220329160934/https://reactjs.org/blog/2022/03/29/react-v18.html|url-status=live}}</ref>
|-
|18.1.0
|26 April 2022
|Many fixes and performance improvements
|-
|18.2.0
|14 June 2022
|Many more fixes and performance improvements
|-
|18.3.0
|25 April 2024
|Adds deprecation warnings for features in React 19.
|-
|19.0.0
|5 December 2024
|Actions, new hooks (useActionState, useFormStatus, useOptimistic), use API, Server Components, Server Actions, passing ref as a normal prop, improved hydration diffs, improved Context API, cleanup functions for refs, improved useDeferredValue API, support for document metadata, support for stylesheets, support for async scripts, support for preloading resources, improved error reporting, and support for custom elements.
|}
 
== Licensing ==
// Skip this line if using Create React Native App
The initial public release of React in May 2013 used the [[Apache License 2.0]]. In October 2014, React 0.12.00 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|access-date=2015-12-09|archive-date=2020-04-28|archive-url=https://web.archive.org/web/20200428042800/https://github.com/facebook/react/blob/master/CHANGELOG.md#0120-october-28-2014|url-status=live}}</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|access-date=2015-12-09|archive-date=2022-05-31|archive-url=https://web.archive.org/web/20220531133320/https://medium.com/bits-and-pixels/a-compelling-reason-not-to-use-reactjs-beac24402f7b|url-status=live}}</ref>
AppRegistry.registerComponent('HelloWorld', () => HelloWorldApp);
 
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/|access-date=2015-12-09|archive-date=2020-11-08|archive-url=https://web.archive.org/web/20201108114832/https://code.facebook.com/posts/1639473982937255/updating-our-open-source-patent-grant/|url-status=live}}</ref>
// The ReactJS code can also be imported into another component with the following code:
 
<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|access-date=2015-12-09|archive-date=2022-05-31|archive-url=https://web.archive.org/web/20220531133320/https://github.com/facebook/react/blob/b8ba8c83f318b84e42933f6928f231dc0918f864/PATENTS|url-status=live}}</ref></blockquote>
import HelloWorldApp from './HelloWorldApp';
</syntaxhighlight>
 
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|archive-date=2018-02-06|archive-url=https://web.archive.org/web/20180206232339/http://www.apache.org/legal/resolved.html|url-status=live}}</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|archive-date=2021-05-06|archive-url=https://web.archive.org/web/20210506164245/https://code.facebook.com/posts/112130496157735/explaining-react-s-license|url-status=live}}</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|archive-date=2022-07-27|archive-url=https://web.archive.org/web/20220727100939/https://github.com/facebook/react/issues/10191#issuecomment-323486580|url-status=live}}</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|date=15 September 2017 |language=en|access-date=2017-09-16|archive-date=2022-05-31|archive-url=https://web.archive.org/web/20220531133350/https://techcrunch.com/2017/09/15/wordpress-to-ditch-react-library-over-facebook-patent-clause-risk/|url-status=live}}</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|accessdate = 2015-12-13}}</ref> However, major changes to React go through the Future of React repository issues and [[Pull request|pull requests]].<ref>{{Cite web|title = reactjs/react-future - The Future of React|url = https://github.com/reactjs/react-future|website = GitHub|accessdate = 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|accessdate = 2015-12-13}}</ref> This enables the React community to provide feedback on new potential features, experimental APIs and JavaScript syntax improvements.
 
On September 23, 2017, Facebook announced that the following week, it would re-license Flow, 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|access-date=2017-09-23|archive-date=2020-12-06|archive-url=https://web.archive.org/web/20201206105641/https://code.facebook.com/posts/300798627056246/relicensing-react-jest-flow-and-immutable-js/|url-status=live}}</ref>
===Sub projects===
The status of the React sub-projects used to be available in the project wiki.<ref>{{Cite web|title = facebook/react Projects wiki|url = https://github.com/facebook/react/wiki/Projects|website = GitHub|accessdate = 2015-12-13}}</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 |access-date=October 18, 2017 |archive-date=October 3, 2017 |archive-url=https://web.archive.org/web/20171003031315/https://reactjs.org/blog/2017/09/26/react-v16.0.html#mit-licensed |url-status=live }}</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 |access-date=October 18, 2017 |archive-date=May 31, 2022 |archive-url=https://web.archive.org/web/20220531133328/https://reactjs.org/blog/2017/09/25/react-v15.6.2.html |url-status=live }}</ref>
===Facebook CLA===
Facebook requires contributors to React to sign the Facebook [[Contributor License Agreement|CLA]].<ref>{{Cite web|title = facebook/react - CONTRIBUTING.md|url = https://github.com/facebook/react/blob/master/CONTRIBUTING.md#contributor-license-agreement-cla|website = GitHub|accessdate = 2015-12-13}}</ref><ref>{{Cite web|title = Contributing to Facebook Projects|url = https://code.facebook.com/cla|website = Facebook Code|accessdate = 2015-12-13}}</ref>
 
== Comparison with other frameworks ==
==Criticism of ReactJS==
JavaScript-based web application frameworks, such as React, provide extensive capabilities but come with associated trade-offs. These frameworks often extend or enhance features available through native web technologies, such as routing, component-based development, and state management. While native web standards, including Web Components, modern JavaScript APIs like Fetch and ES Modules, and browser capabilities like Shadow DOM, have advanced significantly, frameworks remain widely used for their ability to enhance developer productivity, offer structured patterns for large-scale applications, simplify handling edge cases, and provide tools for performance optimization. <ref name=":02">{{Cite book |title=JavaScript Frameworks for Modern Web Development: The Essential Frameworks, Libraries, and Tools to Learn Right Now |isbn=978-1484249949 |last1=Uzayr |first1=Sufyan bin |last2=Cloud |first2=Nicholas |last3=Ambler |first3=Tim |date=November 2019 |publisher=Apress }}</ref><ref name=":12">{{Cite book |title=Building Native Web Components: Front-End Development with Polymer and Vue.js |isbn=978-1484259047}}</ref><ref name=":22">{{Cite book |title=Hands-On JavaScript High Performance: Build faster web apps using Node.js, Svelte.js, and WebAssembly |isbn=978-1838821098}}</ref>
A criticism of ReactJS is that it has high memory (RAM) requirements, since it uses the concept of a "Virtual DOM". This is where "a representation of a UI is kept in memory and synced with the 'real' DOM by a library such as ReactDOM".<ref>https://reactjs.org/docs/faq-internals.html</ref>
 
Frameworks can introduce abstraction layers that may contribute to performance overhead, larger bundle sizes, and increased complexity. Modern frameworks, such as React 18, address these challenges with features like concurrent rendering, tree-shaking, and selective hydration. While these advancements improve rendering efficiency and resource management, their benefits depend on the specific application and implementation context. Lightweight frameworks, such as Svelte and Preact, take different architectural approaches, with Svelte eliminating the virtual DOM entirely in favor of compiling components to efficient JavaScript code, and Preact offering a minimal, compatible alternative to React. Framework choice depends on an application’s requirements, including the team’s expertise, performance goals, and development priorities. <ref name=":02" /><ref name=":12" /><ref name=":22" />
==Licensing controversy==
The initial public release of React in May 2013 used a standard [[Apache License|Apache License 2.0]]. In October 2014, React 0.12.0 replaced this with a [[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>
 
A newer category of web frameworks, including enhance.dev, Astro, and Fresh, leverages native web standards while minimizing abstractions and development tooling. <ref>{{Cite web |title=Enhance |website=[[GitHub]] |url=https://github.com/enhance-dev }}</ref><ref>{{Cite web |title=Astro framework |website=[[GitHub]] |url=https://github.com/withastro/astro }}</ref><ref>{{Cite web |title=Fresh |website=[[GitHub]] |url=https://github.com/denoland/fresh }}</ref> These solutions emphasize [[progressive enhancement]], [[server-side rendering]], and optimizing performance. Astro renders static HTML by default while hydrating only interactive parts. Fresh focuses on server-side rendering with zero runtime overhead. Enhance.dev prioritizes progressive enhancement patterns using Web Components. While these tools reduce reliance on client-side JavaScript by shifting logic to build-time or server-side execution, they still use JavaScript where necessary for interactivity. This approach makes them particularly suitable for performance-critical and content-focused applications. <ref name=":02" /><ref name=":12" /><ref name=":22" />
<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>
 
== See also ==
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>
{{Portal|Free and open-source software}}
* [[Angular (web framework)]]
* [[Backbone.js]]
* [[Ember.js]]
* [[Gatsby (JavaScript framework)]]
* [[Next.js]]
* [[TypeScript]]
* [[Svelte]]
* [[Vue.js]]
* [[Comparison of JavaScript-based web frameworks]]
* [[Web Components]]
 
== Notes ==
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>
{{Notelist}}
 
== References ==
<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>
{{Reflist|2}}
 
== Bibliography ==
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 their 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>
{{Refbegin}}
 
* {{cite book |last=Larsen |first=John |title=React Hooks in Action With Suspense and Concurrent Mode |year=2021 |publisher=Manning |isbn=978-1-72004-399-7}}
On September 23, 2017, Facebook announced that the following week, it would re-license Flow, 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>
* {{cite book |last1=Schwarzmüller |first1=Max |date=2018-05-01 |title=React – The Complete Guide (incl. Hooks, React Router and Redux) |publisher=[[Packt Publishing]] |language=en-US}}
 
* {{cite book |last=Wieruch |first=Robin |title=The Road to React |publisher=Leanpub |isbn=978-1-72004-399-7 |year=2020}}
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>
* {{cite news |last=Dere |first=Mohan |date=2017-12-21 |title=How to integrate create-react-app with all the libraries you need to make a great app |language=en-US |work=freeCodeCamp |url=https://www.freecodecamp.org/news/how-to-make-create-react-app-work-with-a-node-backend-api-7c5c48acb1b0 |access-date=2018-06-14 }}
 
* {{cite news |last=Panchal |first=Krunal |date=2022-04-26 |title=Angular vs React Detailed Comparison |language=en-US |work=SitePoint |url=https://www.sitepoint.com/angular-vs-react/ |access-date=2023-06-05 |archive-date=2023-03-30 |archive-url=https://web.archive.org/web/20230330160838/https://www.sitepoint.com/angular-vs-react/ |url-status=live }}
==See also==
* {{cite news |last1=Hámori |first1=Fenerec |title=The History of React.js on a Timeline |url=https://blog.risingstack.com/the-history-of-react-js-on-a-timeline/ |access-date=2023-06-05 |work=RisingStack |date=2022-05-31 |archive-date=2022-05-31 |archive-url=https://web.archive.org/web/20220531133616/https://blog.risingstack.com/the-history-of-react-js-on-a-timeline/ |url-status=live }}
*[[AngularJS]]
* {{cite news |last=Lardinois |first=Frederic |title=Facebook announces React Fiber, a rewrite of its React framework |date=2017-04-18 |url=https://techcrunch.com/2017/04/18/facebook-announces-react-fiber-a-rewrite-of-its-react-framework/ |access-date=2024-12-31 |website=[[TechCrunch]] }}
*[[Vue.js]]
{{Refend}}
 
==References==
{{Reflist|2}}
<ref>, [https://www.cronj.com/blog/fragments-reactjsv-16-2-0/ "Fragments in ReactJS(v.16.2.0)"], The fragment is a first-class component to wrap your child components and HTML elements instead of using any HTML element - ''Cronj Blog'', </ref>
 
== External links ==
{{Portal|Free software}}
* {{Official website}}
* [https://github.com/facebook/react Github]
 
{{JS templating |state=autocollapse}}
{{Web frameworks}}
{{Rich Internet applications}}
{{Application frameworks}}
{{ECMAScript}}
{{Facebook navbox}}
{{Authority control}}
 
[[Category:2015 software]]
[[Category:Ajax (programming)]]
[[Category:Facebook software]]
[[Category:JavaScript web frameworkslibraries]]
[[Category:RichSoftware Internetusing applicationthe frameworksMIT license]]
[[Category:SoftwareWeb using the BSD licenseapplications]]