Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tame-pumas-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zenml-io/react-component-library": patch
---

fix: wrap function with useCallback
5 changes: 3 additions & 2 deletions src/components/Sidebar/SidebarContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, {
PropsWithChildren,
SetStateAction,
createContext,
useCallback,
useContext,
useState
} from "react";
Expand Down Expand Up @@ -33,7 +34,7 @@ export function SidebarProvider({
* then the sidebar gets automatically closed, instead of waiting for the user
* to hover away from it before closing.
*/
function setIsOpen(newValue: Setter<boolean>): void {
const setIsOpen = useCallback((newValue: Setter<boolean>): void => {
_setIsOpen((currIsOpen) => {
const value: boolean = getValueFromSetter(newValue, currIsOpen);

Expand All @@ -44,7 +45,7 @@ export function SidebarProvider({

return value;
});
}
}, []);

return (
<SidebarContext.Provider value={{ isOpen, setIsOpen, isClosing }}>
Expand Down
Loading