React Holiday

#5: So, what have you learn?

In these first lessons you’ve learned about React 18’s gradual adoption strategy, what each version tag means, and how to use the new root API.

I’d like to test your knowledge with a few questions:

  1. Can you upgrade to React 18 without changing your v17 codebase?
  2. Which future version tag implies the greatest API stability — beta, next, or experimental?
  3. What is the main difference between the legacy root API (v17) and the new root API (v18)?

In the next section we’ll look deeper at the new root API and how to account for its curious omissions.

🐦 chantastic

P.S. I’d like to know how you’re holding up! Hit reply to this email and let me know what you think so far.

🐦 chantastic


Answers:

  1. Yes. If no code changes, the app will run exactly as it did in React 17. However, once you change the root API, you’ll need to migrate all component trees rendered with it.
  2. beta is the React tag alias with the greatest API stability. This version most closely matches what the next version of React will look like.
  3. The legacy root API renders a component to the DOM in one function — ReactDOM.render(<App />, rootNode). The new root API renders components with two functions — ReactDOM.createRoot(<App />).render(rootNote)