File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @zenml-io/react-component-library " : patch
3+ ---
4+
5+ fix: wrap function with useCallback
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import React, {
33 PropsWithChildren ,
44 SetStateAction ,
55 createContext ,
6+ useCallback ,
67 useContext ,
78 useState
89} from "react" ;
@@ -33,7 +34,7 @@ export function SidebarProvider({
3334 * then the sidebar gets automatically closed, instead of waiting for the user
3435 * to hover away from it before closing.
3536 */
36- function setIsOpen ( newValue : Setter < boolean > ) : void {
37+ const setIsOpen = useCallback ( ( newValue : Setter < boolean > ) : void => {
3738 _setIsOpen ( ( currIsOpen ) => {
3839 const value : boolean = getValueFromSetter ( newValue , currIsOpen ) ;
3940
@@ -44,7 +45,7 @@ export function SidebarProvider({
4445
4546 return value ;
4647 } ) ;
47- }
48+ } , [ ] ) ;
4849
4950 return (
5051 < SidebarContext . Provider value = { { isOpen, setIsOpen, isClosing } } >
You can’t perform that action at this time.
0 commit comments