refactor: usedraft hook with TS

This commit is contained in:
Tristan Yang
2022-08-12 20:55:28 +08:00
parent 10a6c9d52f
commit ef9bd40d8c
+3 -2
View File
@@ -1,7 +1,7 @@
import { updateDraftMarkdown, updateDraftMixedText } from "../../app/slices/ui";
import { useAppDispatch, useAppSelector } from "../../app/store";
export default function useDraft({ context = "", id = "" }) {
const useDraft = ({ context = "user", id = 0 }: { context: "user" | "channel"; id: number }) => {
const dispatch = useAppDispatch();
const _key = `${context}_${id}`;
const { draftMarkdown, draftMixedText } = useAppSelector((store) => {
@@ -23,4 +23,5 @@ export default function useDraft({ context = "", id = "" }) {
};
return { getDraft, getUpdateDraft };
}
};
export default useDraft;