Merge pull request #3047 from abhishekjakhar/feat/sidebar-lazy-state-initialization

feat: lazy state initialization of isPinned state of sidebar
This commit is contained in:
Patrik Oldsberg
2020-10-22 19:13:15 +02:00
committed by GitHub
+3 -1
View File
@@ -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);