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

feat(packages/sui-react-router): avoid extra render during first load #1654

Merged
merged 3 commits into from
Nov 6, 2023

Conversation

andresz1
Copy link
Member

@andresz1 andresz1 commented Nov 2, 2023

Description

This PR avoid an extra re-render in the Router component. Normally this causes the application to re-render twice during first load

Related Issue

None

Example

None

@andresz1 andresz1 force-pushed the feat/avoid-router-rerender branch from abe3d62 to 78a6aef Compare November 2, 2023 08:27
@andresz1 andresz1 changed the title test(packages/sui-react-router): avoid extra render during first load feat(packages/sui-react-router): avoid extra render during first load Nov 2, 2023
@@ -66,15 +66,26 @@ const Router = ({

useEffect(() => {
let prevState = {}
let isSkipped = !!matchContext
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If matchContext is provided that means that we can avoid the setState being execute since the router properties are going to be the same

Copy link
Member

@nucliweb nucliweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏🏼

@andresz1 andresz1 merged commit 029a344 into master Nov 6, 2023
1 check passed
@andresz1 andresz1 deleted the feat/avoid-router-rerender branch November 6, 2023 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants