⚡ Bolt: Optimize PasswordScreen FlatList rendering - #185
Conversation
Extracted FlatList renderItem into a memoized useCallback and stabilized row callbacks to prevent unnecessary re-renders of the entire list. Also added windowSize to reduce memory footprint. Co-authored-by: TargetMisser <52361977+TargetMisser@users.noreply.github.com>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a0c58960fd
ℹ️ 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 renderItem = useCallback(({ item }: { item: PasswordEntry }) => ( | ||
| <PasswordRow | ||
| item={item} | ||
| onEdit={openEdit} | ||
| onDelete={deleteEntry} | ||
| /> | ||
| ), [openEdit, deleteEntry]); |
There was a problem hiding this comment.
Move renderItem hook before PIN early returns
When pinMode switches from null to 'unlock' or 'setup' after a normal render, this new useCallback is skipped because the component returns the PIN overlay above it, changing the hook order between renders. That breaks the PIN flows with React's “rendered fewer hooks than expected” runtime error; define this hook before the pinMode early returns or avoid using a hook here.
Useful? React with 👍 / 👎.
💡 What:
Extracted
renderItemusinguseCallbackinPasswordScreen.tsxand modified thePasswordRowComponentcallbacks to prevent inline arrow function instantiation during rendering. AddedwindowSize={5}toFlatList.🎯 Why:
Using inline arrow functions for
renderItemand item callbacks creates new function references on every render. This completely defeated theReact.memowrapping onPasswordRow, forcing re-renders for every single item in the list even if nothing changed.📊 Impact:
Significantly reduces re-renders of the password list. Reduces memory footprint and CPU cycles, making scrolling and screen interactions noticeably smoother, especially as the user adds more items to their password manager.
🔬 Measurement:
You can verify the improvement by using the React DevTools Profiler while typing a PIN or interacting with the screen. You'll see
PasswordRowno longer re-renders unnecessarily compared to the previous state.PR created automatically by Jules for task 10315265784027846532 started by @TargetMisser