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

perf[react-native]: Memoized Blocks Component to free up UI thread. #3814

Merged
merged 7 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/early-pillows-jog.md
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
2 changes: 2 additions & 0 deletions .changeset/nice-llamas-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
99 changes: 65 additions & 34 deletions examples/nextjs-app-dir-v2/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/nextjs-app-dir-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@builder.io/sdk-react": "^1.0.23",
"@builder.io/sdk-react": "^3.0.1",
samijaber marked this conversation as resolved.
Show resolved Hide resolved
"next": "14.1.1",
"react": "^18",
"react-dom": "^18"
Expand Down
15 changes: 15 additions & 0 deletions examples/nextjs-app-dir-v2/src/app/components/MyFunComponent.tsx
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;
18 changes: 18 additions & 0 deletions examples/nextjs-app-dir-v2/src/app/components/register.ts
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',
},
],
},
];
Loading
Loading