Skip to content

Commit

Permalink
minor improvement to performance on decouple menu
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Apr 11, 2024
1 parent 14e86c9 commit 143dce7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions themes/stanford_basic/decoupled-menu/src/main-menu.island.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled from "styled-components";
import {useWebComponentEvents} from "./hooks/useWebComponentEvents";
import {createIslandWebComponent} from 'preact-island'
import {useState, useEffect, useRef, useCallback} from 'preact/hooks';
import {useState, useEffect, useRef, useCallback, useMemo} from 'preact/hooks';
import {deserialize} from "./tools/deserialize";
import {buildMenuTree, MenuContentItem} from "./tools/build-menu-tree";
import {DRUPAL_DOMAIN} from './config/env'
Expand Down Expand Up @@ -155,7 +155,7 @@ export const MainMenu = ({}) => {

useEventListener("keydown", handleEscape);

const menuTree = buildMenuTree(menuItems);
const menuTree = useMemo(() => buildMenuTree(menuItems), [menuItems]);
if (!menuTree.items || menuTree.items?.length === 0) return;

// Remove the default menu.
Expand Down

0 comments on commit 143dce7

Please sign in to comment.