{"id":692,"date":"2021-10-25T11:17:07","date_gmt":"2021-10-25T11:17:07","guid":{"rendered":"https:\/\/externlabs.com\/blogs\/?p=692"},"modified":"2023-04-13T18:53:33","modified_gmt":"2023-04-13T13:23:33","slug":"features-of-upcoming-react-18","status":"publish","type":"post","link":"https:\/\/externlabs.com\/blogs\/features-of-upcoming-react-18\/","title":{"rendered":"Why is New React 18 Special?"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">React 17 was announced last year; It was primarily designed to improve basic groundwork and architecture for upcoming updates and didn&#8217;t offer new features. It was intentionally built for upcoming update adoption to make things easier and faster for the future. Now Facebook and React community is preparing to get us into React 18. On their web blog in June, they have announced that they are working on React 18, and we can expect it next year. As of Now, React 18 is in the alpha stage, and beta builds are just 3 to 5 months away. They mentioned a timeline of their work that we will discuss later, and a dedicated team working on improving alpha React 18, and the community provides them log and bugs. Overall there are a lot of talks and work with React 18; Here, we will discuss All React 18. First, know about ReactJS.<\/p><div id=\"ez-toc-container\" class=\"ez-toc-v2_0_63 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Page Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/externlabs.com\/blogs\/features-of-upcoming-react-18\/#What_is_ReactJS\" title=\"What is ReactJS?\">What is ReactJS?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/externlabs.com\/blogs\/features-of-upcoming-react-18\/#React_18_is_coming\" title=\"React 18 is coming\">React 18 is coming<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/externlabs.com\/blogs\/features-of-upcoming-react-18\/#Whats_new_in_React_18\" title=\"What&#8217;s new in React 18?\">What&#8217;s new in React 18?<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/externlabs.com\/blogs\/features-of-upcoming-react-18\/#Automatic_Batching\" title=\"Automatic Batching\">Automatic Batching<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/externlabs.com\/blogs\/features-of-upcoming-react-18\/#Concurrent_Rendering\" title=\"Concurrent Rendering\">Concurrent Rendering<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/externlabs.com\/blogs\/features-of-upcoming-react-18\/#Root_API\" title=\"Root API\">Root API<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/externlabs.com\/blogs\/features-of-upcoming-react-18\/#Strict_Effect_Mode\" title=\"Strict Effect Mode\">Strict Effect Mode<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_is_ReactJS\"><\/span>What is ReactJS?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/externlabs.com\/blogs\/what-is-react-used-for\/\">React is free to use and helps developers<\/a> to build the user interface and its components. Facebook is the primary maintainer for react with some other individual developers and companies. React is widely use in a single page and mobile application development.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Released by Facebook in 2013, React is a JavaScript library for modern apps and web development. React is used to handle the view layer and can be used to develop both web and mobile applications. In addition, there is a mobile-specific react framework for mobile app development named <a href=\"https:\/\/externlabs.com\/react-native-development.php\">&#8216;React Native.&#8217;<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">React empowers developers to build large web applications that can modify data without reloading the web page. The main objective of React is to be fast, scalable, and simple to work with. React works only on UI or UX in the application. This epistolizes to view in the MVC template. It can be used with a combination of other JavaScript libraries or frameworks, such as AngularJS in MVC.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"React_18_is_coming\"><\/span>React 18 is coming<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"https:\/\/externlabs.com\/blogs\/wp-content\/uploads\/2021\/10\/React-18-1-1024x683.jpg\" alt=\"react 18\" class=\"lazyload_inited wp-image-730\" srcset=\"https:\/\/externlabs.com\/blogs\/wp-content\/uploads\/2021\/10\/React-18-1-1024x683.jpg 1024w, https:\/\/externlabs.com\/blogs\/wp-content\/uploads\/2021\/10\/React-18-1-300x200.jpg 300w, https:\/\/externlabs.com\/blogs\/wp-content\/uploads\/2021\/10\/React-18-1-768x512.jpg 768w, https:\/\/externlabs.com\/blogs\/wp-content\/uploads\/2021\/10\/React-18-1-1536x1024.jpg 1536w, https:\/\/externlabs.com\/blogs\/wp-content\/uploads\/2021\/10\/React-18-1-2048x1365.jpg 2048w, https:\/\/externlabs.com\/blogs\/wp-content\/uploads\/2021\/10\/React-18-1-696x464.jpg 696w, https:\/\/externlabs.com\/blogs\/wp-content\/uploads\/2021\/10\/React-18-1-1392x928.jpg 1392w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">We are currently using React 17.0.2, and React 18 is just a few months away; until then, developers provided alpha builds of React 18 for testing and feedback. With React 18 alpha, we can react to 18&#8217;s upcoming features that we will talk about later in this article.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Every ReactJS user was waiting for something big in the form of an update, and then they just announced ReactJS 18. From React 17, ReactJS Developers kept us in wait and suspense, but now we all know that we will get what we have been waiting for. Still, there might be more stable builds of ReactJS 18, but we will talk about everything that we know so far.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Whats_new_in_React_18\"><\/span>What&#8217;s new in React 18?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Even Alpha Builds includes many changes and new features; then, stable builds will be unique. Here are the features that we have in the latest alpha build of React 18 &#8211;&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Automatic Batching<\/li>\n\n\n\n<li>Concurrent Rendering<\/li>\n\n\n\n<li>Root API<\/li>\n\n\n\n<li>Strict Effect Mode<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Automatic_Batching\"><\/span>Automatic Batching<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Groups of React multiple-state turning into one render for better performance is known as Batching.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Before, we had to batch two or more state updates inside the same event into one rerender batch. This will prevent the half-finished rendering of components. With React 18, All this batching process get change and update. In addition, react 18 Automated this whole process making this batching process more consistent and streamlined.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const App = () =&gt; {\n  const &#91;color, setColor] = useState(0);\n  const &#91;count, setCount] = useState(0);\n  const handleClick = () =&gt; {\n    setColor((count) =&gt; count + 1); \/\/ No re-render yet\n    setCount((count) =&gt; count + 1); \/\/ No re-render yet\n    \/\/ Re-render (updates batched)\n  }\n  return (\n    &lt;div&gt;\n      &lt;button onClick={handleClick}&gt;Next&lt;\/button&gt;\n      &lt;span style={{ color: color % 2 === 0 ? \"blue\" : \"black\" }}&gt;{`${count} ${color % 2 === 0 ? 'Even':'Odd'}`}&lt;\/span&gt;\n    &lt;\/div&gt;\n  );\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">It can always rerender automatic batching no matter where the states are.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Concurrent_Rendering\"><\/span>Concurrent Rendering<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Another significant change seen in React 18 is &#8216;Concurrent Mode&#8217; instead of &#8216;concurrent rendering&#8217; of previous react versions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is not just a name change; this will allow adopting concurrent features without rewriting codes and according to developers. There will be many features in React 18 that might come open; As alpha, not all of them have mention anywhere yet. Here are some concurrent mode features that we know for now &#8211;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>startTransition: Keeps the user interface interactive even during Big transitions.<\/li>\n\n\n\n<li>&lt;SuspenseList&gt;: Loading Indicators order co-ordinator<\/li>\n\n\n\n<li>Server-Side Rendering with selective Hydration: Helps in reducing loading time and be interactive and fast.<\/li>\n\n\n\n<li>useDeferredValue: defer the update for your app<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The best part about all these features is that we don&#8217;t have to include them throughout the whole development; We can choose to build with these as opt-in at any part of the app.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This made the new Concurrent Mode more fast, productive, effortless, and efficient.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Root_API\"><\/span>Root API<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Root API is a pointer for data structure in previous versions of React. They are primarily use to track render trees. With the new React 18, It will deploy two different root APIs, Legacy root API and the new ReactDOM.createRoot. the legacy root will run legacy mode in ReactDOM.createRoot API. This ReactDOM.createRoot can integrate improvements to the app efficiently and add a deprecated warning.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Old root API<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import React from 'react';\nimport ReactDOM from 'react-dom;\nimport App from 'App';\nReactDOM.render(&lt;App \/&gt;, document.getElementById('root'));<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">New Root API<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import ReactDOM from 'react-dom';\nimport App from 'App';\nconst root = ReactDOM.createRoot(document.getElementById('root'));\nroot.render(&lt;App \/&gt;);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Strict_Effect_Mode\"><\/span>Strict Effect Mode<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">React 18 will provide Strict Effect Mode, which will improve DX and development versions. With this react can detect unusual movement by running side effects twice like-<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mount-&gt; unmount-&gt; mount<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">React 18 will be a vast improvement, and we are all going to leverage its advanced features. Developers are halfway through the development yet, still impressed users with these fantastic features. You can try Alpha ReactJS 18 from their website or wait for 3 to 5 months for a richer stable build.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>React 17 was announced last year; It was primarily designed to improve basic groundwork and architecture for upcoming updates and didn&#8217;t offer new features. It was intentionally built for upcoming update adoption to make things easier and faster for the future. Now Facebook and React community is preparing to get us into React 18. On&hellip;<\/p>\n","protected":false},"author":2,"featured_media":6814,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"content-type":"","footnotes":""},"categories":[42],"tags":[149,249,250],"class_list":["post-692","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-javascript-libraries","tag-react-18-beta","tag-react-18-new-hooks"],"_links":{"self":[{"href":"https:\/\/externlabs.com\/blogs\/wp-json\/wp\/v2\/posts\/692","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/externlabs.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/externlabs.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/externlabs.com\/blogs\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/externlabs.com\/blogs\/wp-json\/wp\/v2\/comments?post=692"}],"version-history":[{"count":0,"href":"https:\/\/externlabs.com\/blogs\/wp-json\/wp\/v2\/posts\/692\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/externlabs.com\/blogs\/wp-json\/wp\/v2\/media\/6814"}],"wp:attachment":[{"href":"https:\/\/externlabs.com\/blogs\/wp-json\/wp\/v2\/media?parent=692"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/externlabs.com\/blogs\/wp-json\/wp\/v2\/categories?post=692"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/externlabs.com\/blogs\/wp-json\/wp\/v2\/tags?post=692"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}