自定义Hook返回状态与setState时出现TypeScript错误求助
The issue here is a case sensitivity mismatch between the property name you're returning from your useProcesses hook and the one you're trying to destructure when calling the hook.
Looking at your hook's return statement:
return [{ Processes, isLoading, isError }, setProcesses];
You're using a capitalized Processes as the key in the returned object, but your state variable is actually named processes (lowercase p). When you call the hook:
const [{ processes, isLoading, isError }, setProcesses] = useProcesses(...);
You're trying to access a property named processes (lowercase), which doesn't exist on the returned object—hence the TypeScript error.
The Fix
Update the return statement to use the lowercase processes (matching your state variable name):
return [{ processes, isLoading, isError }, setProcesses];
This aligns the property name with what you're destructuring, resolving the Property 'processes' does not exist error.
TypeScript is strictly case-sensitive, so even small differences like uppercase vs lowercase will trigger these kinds of errors. It's a good practice to keep variable and property names consistent in casing to avoid this.
内容的提问来源于stack exchange,提问作者LikeAKemper

