DEV Community

Cover image for React 19 updates you should know
Rahman Adewale
Rahman Adewale

Posted on

React 19 updates you should know

Key React v19 updates

React Compiler: With the addition of the React Compiler we would no longer have to manually manage issues of the unexpected re-rendering of our React applications. The React compiler takes care of this for us by determining where in our the memorization is needed, this leads to a less verbose code since we would no longer need to have hooks like useMemo, useCallback and 'Memo' HOC components and it also would help increase the performance of our apps since the compiler would know better where memoization should be added. It takes suit from frameworks like Astro and Svelte.

Actions: With Actions, managing forms just became better, we can now get access to the form’s state through hooks like useFormState or useFormStatus, with these hooks we can now get access to the error state, loading state and data of the form without too many lines of code. This will be very useful for simple forms. It operates both synchronously and asynchronously

useOptimistic Hook: This is very similar to the optimistic fetching from React query, with this we would be able to pass the UI an expected state through a function while the actual request is still processing. If the request or process fails it reverts to the previous state, if it doesn't, it updates the actual state value.

Document MetaData: With the new update, we can now add the <title>, <link> and <meta> tags anywhere in the component tree and we can expect that will be rendered at the top of the file (index.html). This helps remove the need for packages like React Helmet and the useTitle Hook from react-use.

Asset Loading: The introduction of Suspense would allow us to decide when a page should be loaded by waiting for certain assets, this would be useful for use when we want to load multi-tenant data before our screen loads, seems like something similar the Angular’s Resolve interface

Lazy Loading: We will no longer need to use React.Lazy to lazy load components, we can now leverage the use of the use hook from this new update, it performs different functions one of which is lazy loading. It not only lazy loads components, it also lazy loads JS files, promises and even contexts. This hook is slightly more complex and this is just a tiny part of its use cases

Top comments (0)