React 开发报错整理
创始人
2025-01-15 13:05:48
0

1、'yield' expression implicitly results in an 'any' type because its containing generator lacks a return-type annotation.

function* handleSignin(action: SigninAction) {     console.log(action, 'handleSignin')     try{         let res: any = yield call(axios.post, `${API}/signin`, action.payload)         yield put(signinSuccess())     }catch(error:any) {         alert(error.response.data.error)         yield put(signinFail(error.response.data.error))     }      }
function* handleSignin(action: SigninAction): any {     console.log(action, 'handleSignin')     try{         let res: any = yield call(axios.post, `${API}/signin`, action.payload)         yield put(signinSuccess())     }catch(error:any) {         alert(error.response.data.error)         yield put(signinFail(error.response.data.error))     }      }

2、React Hook "useActive" is called conditionally. React Hooks must be called in the exact same order in every component render

function useActive(currentPath:string, path:string) {     return currentPath === path ? 'ant-menu-item-selected' : '' }  function getDashboardUrl() {     let url = '/user/dashboard'     if(isAuth()) {         const {             user: {role}          } = isAuth() as Jwt         if(role === 1) {             url = '/admin/dashboard'         }     }     return url } 
function getDashboardUrl() {     let url = '/user/dashboard'     if(isAuth()) {         const {             user: {role}          } = isAuth() as Jwt         if(role === 1) {             url = '/admin/dashboard'         }     }     return url }   function useActive(currentPath:string, path:string) {     return currentPath === path ? 'ant-menu-item-selected' : '' }

3、An interface can only extend an object type or intersection of object types with statically known members

是类和接口不能 implement / extends 联合类型的类型别名。就像你用 interface 去 extends 一个 class 或另一个 interface 是可以的,但是你不能去 extends 联合类型。

interface PrivateRouteProps extends RouteProps {}
type PrivateRouteProps = RouteProps & {}

4、An argument for 'defaultValue' was not provided

5、Argument of type 'RcFile | undefined' is not assignable to parameter of type 'string | Blob'.
Type 'undefined' is not assignable to type 'string | Blob'.

6、Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.

const {productId} = useParams<{ productId: string }>()     useEffect(() => {                  dispatch(getDetailProduct({productId}))     }, [])
const {productId} = useParams<{ productId: string }>()     useEffect(() => {         //dispatch(getDetailProduct({productId: productId!}))         dispatch(getDetailProduct({productId: productId as string}))     }, [])

相关内容

热门资讯

透视系统!智星德州可以透视吗,... 透视系统!智星德州可以透视吗,广西八一字牌辅助app,揭秘攻略(有挂教程)暗藏猫腻,小编详细说明广西...
揭秘几款“随意玩辅助器视频”真... 揭秘几款“随意玩辅助器视频”真是是有挂(辅助挂)详细辅助第三方教程;1、完成随意玩辅助器的残局,帮助...
2分钟辅助!微信微乐辅助器下载... 2分钟辅助!微信微乐辅助器下载(辅助挂)原生有挂(详细辅助软件教程);小薇(透视辅助)致您一封信;亲...
透视ai代打!欢乐情怀挂,潘潘... 透视ai代打!欢乐情怀挂,潘潘讲故事辅助器,2025新版教程(有挂透视);最新版2024是一款经典耐...
第8分钟辅助(闲来游戏辅助器脚... 第8分钟辅助(闲来游戏辅助器脚本)本来存在有挂(详细辅助切实教程)亲,关键说明,闲来游戏辅助器脚本赛...
透视游戏!德普之星私人局辅助器... 透视游戏!德普之星私人局辅助器,微信小程序微乐房间怎么开挂,黑科技教程(有挂解密)1、该软件可以轻松...
8分钟辅助!九游辅助器(辅助挂... 8分钟辅助!九游辅助器(辅助挂)原本真的是有挂(详细辅助2025版教程)是一款可以让一直输的玩家,快...
五分钟辅助(小逸碰胡插件脚本)... 五分钟辅助(小逸碰胡插件脚本)切实真的有挂(详细辅助线上教程);小逸碰胡插件脚本辅助器中分为三种模型...
今日公布“中至余干小程序辅助透... 今日公布“中至余干小程序辅助透视”原来是真的有挂(辅助挂)详细辅助必胜教程1)辅助挂:进一步探索辅助...
透视好友房!天天微友有辅助吗,... 这是一款非常优秀的天天微友有辅助吗 ia辅助检测软件,能够让你了解到天天微友有辅助吗中牌率当中全部隐...