fix: react infinite depth error

This commit is contained in:
Prayag Prajapati committed 2024-09-29 00:02:47 +05:30
1 parent d78676560f
commit a1bb8f8e23
19 files changed
+377 -370

No files matched your search

+4 -2
View File
@@ -1,7 +1,9 @@
import { type Api, Jellyfin } from "@jellyfin/sdk";
import React, { type ReactNode } from "react";
import { createContext, useContext, useState } from "react";
import { type StoreApi, createStore, useStore } from "zustand";
import { type StoreApi, createStore } from "zustand";
import { shallow } from "zustand/shallow";
import { useStoreWithEqualityFn } from "zustand/traditional";
import { version as appVer } from "../../../package.json";
// Initial custom axios client to use tauri's http module
@@ -69,5 +71,5 @@ export function useApiInContext<T>(selector?: (state: ApiStore) => T) {
if (!store) {
throw new Error("Missing ApiProvider");
}
return useStore(store, selector!);
return useStoreWithEqualityFn(store, selector!, shallow);
}