chore: redirect to last visited market - improve use of zustand

This commit is contained in:
maciek
2023-01-02 13:45:38 +01:00
parent b6581dec41
commit d53e66ebe3
2 changed files with 6 additions and 12 deletions
+2 -4
View File
@@ -13,10 +13,8 @@ export const Home = () => {
const { data, error, loading } = useDataProvider({
dataProvider: marketsWithDataProvider,
});
const { update, marketId } = useGlobalStore((store) => ({
update: store.update,
marketId: store.marketId,
}));
const update = useGlobalStore((store) => store.update);
const marketId = useGlobalStore((store) => store.marketId);
useEffect(() => {
if (marketId) {
+4 -8
View File
@@ -36,15 +36,11 @@ export const Market = () => {
const navigate = useNavigate();
const { w } = useWindowSize();
const { update, marketId: lastMarketId } = useGlobalStore((store) => ({
update: store.update,
marketId: store.marketId,
}));
const update = useGlobalStore((store) => store.update);
const lastMarketId = useGlobalStore((store) => store.marketId);
const { pageTitle, updateTitle } = usePageTitleStore((store) => ({
pageTitle: store.pageTitle,
updateTitle: store.updateTitle,
}));
const pageTitle = usePageTitleStore((store) => store.pageTitle);
const updateTitle = usePageTitleStore((store) => store.updateTitle);
const onSelect = useCallback(
(id: string) => {