Skip to content

Commit

Permalink
Merge pull request #3047 from abhishekjakhar/feat/sidebar-lazy-state-…
Browse files Browse the repository at this point in the history
…initialization

feat: lazy state initialization of isPinned state of sidebar
  • Loading branch information
Rugvip committed Oct 22, 2020
2 parents 5a1eb83 + a856fa8 commit 628f782
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/core/src/layout/Sidebar/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export const SidebarPinStateContext = createContext<SidebarPinStateContextType>(
);

export const SidebarPage: FC<{}> = props => {
const [isPinned, setIsPinned] = useState(LocalStorage.getSidebarPinState());
const [isPinned, setIsPinned] = useState(() =>
LocalStorage.getSidebarPinState(),
);

useEffect(() => {
LocalStorage.setSidebarPinState(isPinned);
Expand Down

0 comments on commit 628f782

Please sign in to comment.