TopNav: Wrap TopSearchBar in memo to prevent unnecessary re-renders (#64667)

This commit is contained in:
Torkel Ödegaard 2023-03-13 10:57:55 +01:00 committed by GitHub
parent 5ffb28989e
commit 5275a203aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,7 +19,7 @@ import { TopSearchBarSection } from './TopBar/TopSearchBarSection';
import { TopSearchBarCommandPaletteTrigger } from './TopSearchBarCommandPaletteTrigger';
import { TOP_BAR_LEVEL_HEIGHT } from './types';
export function TopSearchBar() {
export const TopSearchBar = React.memo(function TopSearchBar() {
const styles = useStyles2(getStyles);
const navIndex = useSelector((state) => state.navIndex);
const location = useLocation();
@ -67,7 +67,7 @@ export function TopSearchBar() {
</TopSearchBarSection>
</div>
);
}
});
const getStyles = (theme: GrafanaTheme2) => ({
layout: css({