react 18 notes

 

React 18 is the next major release of react. These are some notes

  • react 18 big theme: concurrent react
    • improve UI performance, lessen janky experiences
    • a way to keep pages interactive even when doing other things
  • createRoot; use React.createRoot() instead of ReactDOM.render() and then call render of your app into the root
    • using root enables using react concurrent feature
    • root is pointer to top level data structure in react, previously not exposed
    • ReactDOM.render still supported but warned is "no longer supported"
    • React.createRoot(<App />, rootElement) .render(<App />)
  • automatic batching; react 18 will be batched and will prevent multiple re-renders
    • react 17 batched but did not batch state updates in promises, react 18 does
    • react 18 waits until the end of microtask
  • upgrade react and react-dom to 18 to use
  • startTransition; mark urgent updates to show faster and let React know ok to interrupt non urgent updates
    • startTransition(() => { ...do stuff.. }
    • useful if rendering a lot of data or slow network


Resources
  • meetup 
  • "explain like I'm five"

Comments

Popular posts from this blog

deep dive into Material UI TextField built by mui

angular js protractor e2e cheatsheet

react-router v6.4+ loaders, actions, forms and more