Skip to content

perf(Blocks,Block): add deep comparison to block/blocks memo call#4253

Open
jakequade-pc wants to merge 1 commit intoBuilderIO:mainfrom
jakequade-pc:perf-react-native-deep-memo-comparison
Open

perf(Blocks,Block): add deep comparison to block/blocks memo call#4253
jakequade-pc wants to merge 1 commit intoBuilderIO:mainfrom
jakequade-pc:perf-react-native-deep-memo-comparison

Conversation

@jakequade-pc
Copy link

@jakequade-pc jakequade-pc commented Jan 27, 2026

Description

React.memo uses a shallow comparison, which isn't enough in this case.

Using welldone-software/why-did-you-render

I found our app home-screen content would update 12 times in one load with the wdyr message

"different objects that are equal by value".

This change adds a deep comparison, which when tested via patch-package, eliminated those re-renders.

Note: I tried to base this PR on the one that initially made these memo changes, hope it's okay :)

Screenshot

CleanShot 2026-01-27 at 19 59 52@2x

Note

Medium Risk
Touches generated component wrapping and adds a new runtime dependency; deep comparison can change update behavior and has potential performance tradeoffs on large props.

Overview
Reduces unnecessary re-renders in the React Native SDK by switching Block and Blocks exports from memo(Component) to memo(Component, isEqual) using react-fast-compare (deep equality) via the Mitosis MEMOIZING_BLOCKS_COMPONENT_PLUGIN.

Adds react-fast-compare as a dependency of @builder.io/sdk-react-native and includes a patch changeset documenting the perf improvement.

Written by Cursor Bugbot for commit 77421c5. This will update automatically on new commits. Configure here.

Cursor Bugbot reviewed your changes and found no issues for commit 77421c5

@changeset-bot
Copy link

changeset-bot bot commented Jan 27, 2026

🦋 Changeset detected

Latest commit: 77421c5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@builder.io/sdk-react-native Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jakequade-pc
Copy link
Author

jakequade-pc commented Jan 27, 2026

cc @samijaber @sidmohanty11 just for visibility 😊 thanks for your time!

@nx-cloud
Copy link

nx-cloud bot commented Jan 30, 2026

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit 77421c5

Command Status Duration Result
nx test @e2e/react-native-76-fabric ❌ Failed 4m 14s View ↗
nx test @e2e/react-native-74 ❌ Failed 4m 13s View ↗
nx test @snippet/react ✅ Succeeded 1m 56s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-05 05:05:13 UTC

@sidmohanty11
Copy link
Contributor

thanks @jakequade-pc for the PR, looks good to me - tagging @midhunadarvin to take a look once on why the tests aren't running and help out

@midhunadarvin midhunadarvin self-assigned this Feb 4, 2026
@midhunadarvin
Copy link
Contributor

@jakequade-pc Could you rebase your branch with the main branch ? The e2e tests should run properly once you've rebased.

React.memo uses a shallow comparison, which isn't enough in this case.

Using [welldone-software/why-did-you-render](https://github.com/welldone-software/why-did-you-render)

I found our homepage content would update 12 times in one load with the wdyr message

"different objects that are equal by value".

This change adds a deep comparison, which when tested via patch-package, eliminated those re-renders.
@jakequade-pc jakequade-pc force-pushed the perf-react-native-deep-memo-comparison branch from ad3738b to 77421c5 Compare February 4, 2026 22:00
@jakequade-pc
Copy link
Author

@midhunadarvin done! Thanks for your patience with this

@midhunadarvin
Copy link
Contributor

@jakequade-pc There are a couple of E2E test workflows failing :
https://github.com/BuilderIO/builder/actions/runs/21690062241/job/62576597925?pr=4253
https://github.com/BuilderIO/builder/actions/runs/21690062241/job/62576597914?pr=4253

Could you take a look at the failing test cases and try to resolve them ? Let me know if you need any additional help.

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.

3 participants