1/n Use zustand to reduce re-renders
This commit is contained in:
parent
3dc2e3eace
commit
e6ef3ff23f
14 changed files with 210 additions and 87 deletions
21
crates/librqbit/webui/src/stores/errorStore.ts
Normal file
21
crates/librqbit/webui/src/stores/errorStore.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { create } from "zustand";
|
||||
import { ErrorDetails } from "../api-types";
|
||||
|
||||
export interface ErrorWithLabel {
|
||||
text: string;
|
||||
details?: ErrorDetails;
|
||||
}
|
||||
|
||||
export const useErrorStore = create<{
|
||||
closeableError: ErrorWithLabel | null;
|
||||
setCloseableError: (error: ErrorWithLabel | null) => void;
|
||||
|
||||
otherError: ErrorWithLabel | null;
|
||||
setOtherError: (error: ErrorWithLabel | null) => void;
|
||||
}>((set) => ({
|
||||
closeableError: null,
|
||||
setCloseableError: (closeableError) => set(() => ({ closeableError })),
|
||||
|
||||
otherError: null,
|
||||
setOtherError: (otherError) => set(() => ({ otherError })),
|
||||
}));
|
||||
Loading…
Add table
Add a link
Reference in a new issue