-
Notifications
You must be signed in to change notification settings - Fork 982
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf[react-native]: Memoized Blocks Component to free up UI thread. (#…
…3814) ## Description `Suspense`: Added `React.Suspense` to defer the rendering of the `Content` component until it is fully loaded. `Memoization`: `React.memo` to memoize computationally expensive operations within the `Blocks` component. To prevents unnecessary recalculations of processed blocks during re-renders, reducing the load on the UI thread. _Screenshot_ Before: <img width="798" alt="Screenshot 2025-01-13 at 12 20 38 PM" src="https://github.com/user-attachments/assets/91ddb89c-2ddd-4930-b62f-7497783ad948" /> After: <img width="798" alt="Screenshot 2025-01-13 at 12 37 41 PM" src="https://github.com/user-attachments/assets/6dd776b0-3d82-46f1-a98a-7d28e553d44c" /> --------- Co-authored-by: Yash Wadhia <[email protected]>
- Loading branch information
1 parent
eb3d1af
commit 12b35b2
Showing
9 changed files
with
194 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@builder.io/sdk-react-native": patch | ||
--- | ||
|
||
- Enchanced performance: Implemented memoization for the Blocks components | ||
- Flatlist usage: Configured Flatlist for smoother rendering of block components | ||
These changes aims to improve UI responsiveness and reduce rendering overhead |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
--- |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
examples/nextjs-app-dir-v2/src/app/components/MyFunComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use client'; | ||
import { useState } from 'react'; | ||
|
||
export const MyFunComponent = (props: { text: string }) => { | ||
const [count, setCount] = useState(0); | ||
return ( | ||
<div> | ||
<h3>{props.text.toUpperCase()}</h3> | ||
<p>{count}</p> | ||
<button onClick={() => setCount(prev => prev + 1) }>Click me</button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default MyFunComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
'use client'; | ||
import dynamic from 'next/dynamic'; | ||
import { type RegisteredComponent } from "@builder.io/sdk-react"; | ||
|
||
export const customComponents: RegisteredComponent[] = [ | ||
{ | ||
component: dynamic(() => import('./MyFunComponent')), | ||
name: 'MyFunComponent', | ||
inputs: [ | ||
{ | ||
name: 'text', | ||
type: 'string', | ||
defaultValue: 'Hello world', | ||
}, | ||
], | ||
}, | ||
]; |
Oops, something went wrong.