Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refreshed React 18 concepts #108

Open
reboottime opened this issue Oct 23, 2024 · 1 comment
Open

Refreshed React 18 concepts #108

reboottime opened this issue Oct 23, 2024 · 1 comment

Comments

@reboottime
Copy link
Owner

reboottime commented Oct 23, 2024

Overview

This article systematically track through React 18.

It’s a new behind-the-scenes mechanism that enables React to prepare multiple versions of your UI at the same time

  • useTransition
  • new Application of Suspense
@reboottime
Copy link
Owner Author

reboottime commented Oct 23, 2024

useTransition

https://www.youtube.com/watch?v=1xjSQJWejZM&ab_channel=CosdenSolutions.

Understand it using plain term

Let me explain useTransition in React 18+ in a business-friendly way.

Imagine you're running a busy restaurant. When customers place orders, you have two options:

  1. Traditional way (without useTransition): Your waitstaff stops everything they're doing to process each order immediately. While this sounds efficient, it can make the restaurant feel "frozen" or unresponsive during busy times, frustrating other customers.

  2. Using useTransition: This is like having your waitstaff say "I'll get right on that" to the customer (keeping the interface responsive), while processing the order in the background. The restaurant keeps running smoothly, and customers can continue interacting with menus or asking questions.

In technical terms, useTransition allows your app to:

  • Maintain responsiveness during heavy updates
  • Prioritize immediate user interactions over less urgent background updates
  • Provide better user experience during complex operations

Business Benefits:

  • Higher user satisfaction due to more responsive interfaces
  • Lower bounce rates as users don't encounter "frozen" screens
  • Better handling of resource-intensive operations

Understanding it from code level

// Without useTransition
setActiveTab(tab);  // This blocks rendering until complete

// With useTransition
startTransition(() => {
    setActiveTab(tab);  // This can be interrupted by other updates
                        // and keeps old UI visible while processing
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant