lazy state initialization of isPinned state of sidebar

This commit is contained in:
Abhishek Jakhar
2020-10-22 22:00:28 +05:30
parent bc9f536545
commit a856fa8d94
+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);