Skip to content

⚡ Bolt: Optimize PasswordScreen FlatList re-renders - #180

Open
TargetMisser wants to merge 1 commit into
mainfrom
bolt-optimize-passwordscreen-flatlist-11420094054483967941
Open

⚡ Bolt: Optimize PasswordScreen FlatList re-renders#180
TargetMisser wants to merge 1 commit into
mainfrom
bolt-optimize-passwordscreen-flatlist-11420094054483967941

Conversation

@TargetMisser

Copy link
Copy Markdown
Owner

💡 What:
Optimized the FlatList inside PasswordScreen.tsx by using a stabilized renderItem function (useCallback), passing down stable callback references to PasswordRowComponent, and introducing windowSize={5}.

🎯 Why:
The PasswordRow component was wrapped in React.memo, but it was receiving inline arrow functions (onEdit={() => openEdit(item)} and onDelete={() => deleteEntry(item.id)}) on every render. This defeated React.memo's shallow equality check, causing all items in the list to re-render whenever the screen state updated.

📊 Impact:

  • Drastically reduces unnecessary re-renders of the list items when the screen updates (e.g. typing in search, opening modals).
  • Reduces memory footprint by limiting the number of off-screen items rendered via windowSize={5}.

🔬 Measurement:
Start the app and navigate to the passwords screen. Monitor component re-renders (using React DevTools) while adding a password or opening the modal. Previously, all rows would re-render; now, only the modified elements re-render. Verify memory profile is more stable when scrolling due to lowered windowSize.


PR created automatically by Jules for task 11420094054483967941 started by @TargetMisser

- Wrap renderItem in useCallback and pass stable function references to PasswordRow
- Adjust PasswordRowComponent to accept specific item and pass it to handlers, avoiding inline closures
- Add windowSize=5 to FlatList to reduce memory usage off-screen
- Add performance improvement comment

Co-authored-by: TargetMisser <52361977+TargetMisser@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel

vercel Bot commented May 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
flight-work-app Ready Ready Preview, Comment, Open in v0 May 8, 2026 1:16am

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e866db6d72

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}


const renderPasswordItem = useCallback(({ item }: { item: PasswordEntry }) => (

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Move the new hook above PIN early returns

When PIN protection is enabled, the load effect sets pinMode to unlock, so the component renders the PIN overlay and returns before this new useCallback; after the user unlocks, the next render reaches this extra hook, changing the hook count/order and causing React to throw a hook-order error. Define renderPasswordItem before the pinMode early returns so every render calls the same hooks.

Useful? React with 👍 / 👎.

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.

1 participant