mirror of
https://github.com/yuruotong1/autoMate.git
synced 2025-12-26 05:16:21 +08:00
✨ 添加(components/CategoryItem/index.tsx):引入useFetcher钩子替代useSubmit钩子
💡 注释(components/CategoryItem/index.tsx):添加关于fetcher的注释
This commit is contained in:
parent
2f662e5308
commit
6997e953d4
@ -1,5 +1,5 @@
|
||||
import { Delete, FolderClose } from "@icon-park/react"
|
||||
import { NavLink, useSubmit } from "react-router-dom"
|
||||
import { NavLink, useFetcher, useSubmit } from "react-router-dom"
|
||||
import styles from "./styles.module.scss"
|
||||
import { useContextMenu } from "mantine-contextmenu"
|
||||
import { useStore } from "@renderer/store/useStore"
|
||||
@ -8,7 +8,8 @@ interface Props {
|
||||
}
|
||||
|
||||
export const CategoryItem = ({ category }: Props) => {
|
||||
const submit = useSubmit()
|
||||
// fetcher 不会刷新路由
|
||||
const fetcher = useFetcher()
|
||||
const { showContextMenu } = useContextMenu()
|
||||
const setEditCategoryId = useStore(state => state.setEditCategoryId)
|
||||
const editCategoryId = useStore(state => state.editCategoryId)
|
||||
@ -23,7 +24,7 @@ export const CategoryItem = ({ category }: Props) => {
|
||||
onKeyDown={
|
||||
(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
submit({ id: category.id, name: e.currentTarget.value }, { method: 'PUT' })
|
||||
fetcher.submit({ id: category.id, name: e.currentTarget.value }, { method: 'PUT' })
|
||||
setEditCategoryId(0)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user