mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-22 19:14:33 -07:00
Fix hooks to avoid unnecessary re-renders (#10820)
This commit is contained in:
committed by
GitHub
parent
b60c8858af
commit
cd354aebed
@@ -4,7 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { useState, useRef, useCallback } from 'react';
|
||||
import { useState, useRef, useCallback, useMemo } from 'react';
|
||||
import type { HistoryItem } from '../types.js';
|
||||
|
||||
// Type for the updater function passed to updateHistoryItem
|
||||
@@ -101,11 +101,14 @@ export function useHistory(): UseHistoryManagerReturn {
|
||||
messageIdCounterRef.current = 0;
|
||||
}, []);
|
||||
|
||||
return {
|
||||
history,
|
||||
addItem,
|
||||
updateItem,
|
||||
clearItems,
|
||||
loadHistory,
|
||||
};
|
||||
return useMemo(
|
||||
() => ({
|
||||
history,
|
||||
addItem,
|
||||
updateItem,
|
||||
clearItems,
|
||||
loadHistory,
|
||||
}),
|
||||
[history, addItem, updateItem, clearItems, loadHistory],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user