forked from imbytecat/fullstack-starter
refactor: 更新事件处理函数类型定义
- 更新事件处理函数类型以使用更精确的类型定义,提升代码可读性和类型安全性。
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useMutation, useSuspenseQuery } from '@tanstack/react-query'
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import type { ChangeEvent, FormEvent } from 'react'
|
||||
import type { ChangeEventHandler, FormEventHandler } from 'react'
|
||||
import { useState } from 'react'
|
||||
import { orpc } from '@/orpc'
|
||||
|
||||
@@ -19,7 +19,7 @@ function Todos() {
|
||||
const updateMutation = useMutation(orpc.todo.update.mutationOptions())
|
||||
const deleteMutation = useMutation(orpc.todo.remove.mutationOptions())
|
||||
|
||||
const handleCreateTodo = (e: FormEvent<HTMLFormElement>) => {
|
||||
const handleCreateTodo: FormEventHandler<HTMLFormElement> = (e) => {
|
||||
e.preventDefault()
|
||||
if (newTodoTitle.trim()) {
|
||||
createMutation.mutate({ title: newTodoTitle.trim() })
|
||||
@@ -27,7 +27,7 @@ function Todos() {
|
||||
}
|
||||
}
|
||||
|
||||
const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const handleInputChange: ChangeEventHandler<HTMLInputElement> = (e) => {
|
||||
setNewTodoTitle(e.target.value)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user