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}))     }, [])

相关内容

热门资讯

有挂!德州私人局怎么透视,九游... 【福星临门,好运相随】;有挂!德州私人局怎么透视,九游破解版真的假的,解密教程(果然有挂);暗藏猫腻...
真的是有挂!we poker游... 真的是有挂!we poker游戏下,情怀透明器看手机纸牌,插件教程(一直真的是有挂);AI辅助机器人...
真的是有挂!hhpoker辅助... 真的是有挂!hhpoker辅助器视频,创思维辅助器,力荐教程(果然真的是有挂);创思维辅助器是一款益...
有挂!aapoker脚本,赣牌... 有挂!aapoker脚本,赣牌圈插件,解说技巧(原来有挂);赣牌圈插件软件透视开挂更新新赛季,主要更...
是有挂!wpk有那种辅助吗,哥... 是有挂!wpk有那种辅助吗,哥哥打大a辅助工具视频,存在挂教程(一贯是有挂);1、完成哥哥打大a辅助...
确实有挂!德扑之心免费透视,欢... 确实有挂!德扑之心免费透视,欢乐情怀辅助卦,规律教程(一贯确实有挂);欢乐情怀辅助卦是一项欢乐情怀辅...
是有挂的!佛手在线大菠萝辅助,... 是有挂的!佛手在线大菠萝辅助,免费宝宝浙江游戏安装,技巧教程(一直是有挂的);大家肯定在之前免费宝宝...
真的是有挂!来玩app 德州 ... 真的是有挂!来玩app 德州 辅助,同乡游辅助软件下载,靠谱教程(一贯真的是有挂);1.同乡游辅助软...
有挂!德州局透视脚本,宝宝浙江... 有挂!德州局透视脚本,宝宝浙江游戏有挂吗,存在挂教程(果然有挂);宝宝浙江游戏有挂吗软件透视开挂更新...
真的有挂!wepoker有透视... 真的有挂!wepoker有透视底牌吗,打哈儿小程序辅助,黑科技教程(其实真的有挂);最新版2026是...