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

[Advanced React] Intro to rerender #71

Open
reboottime opened this issue Apr 26, 2024 · 3 comments
Open

[Advanced React] Intro to rerender #71

reboottime opened this issue Apr 26, 2024 · 3 comments

Comments

@reboottime
Copy link
Owner

reboottime commented Apr 26, 2024

Intro to re-render

This article is part of an advanced React series tutorials.

Major content

  • How to make explanation: Problem - Fundamental -> Solution
  • The problem, the app reacts too slow on clicking the button to render a modal
  • The fundamental: state change triggers re-rendering, and the rendering tree
  • The solution: move modal related logic down to ModalWithButton
@reboottime
Copy link
Owner Author

reboottime commented Apr 26, 2024

The problem

In the following UI, clicking on the Click Me button takes forever to render the modal

image
  • Code structure
image

@reboottime
Copy link
Owner Author

reboottime commented Apr 26, 2024

The fundamental

How react adds, updates and removes component on the screen.

  • First time mounting
image
  • unmounting
image
  • rendering
image
  • re-rendering tree
image

Be careful with hooks

  • Each place where you use hooks will create a separate state instance.
  • Hooks hide the internal logic, so you may not have noticed it in places where you use it
image

@reboottime reboottime changed the title [Advanced React] Intro t rerender [Advanced React] Intro to rerender Apr 26, 2024
@reboottime
Copy link
Owner Author

Solution

Root cause: So the problem happens because the heavier components take a lot of time on re rendering, thus the modal shows slow to the screen

Solution: Minimize the influence scope of rerendering

Solution So the problem happens because the heavier components take a lot of time on re rendering, thus the modal shows slow to the screen

image

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