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

相关内容

热门资讯

绝活儿透视挂!中至余干可以装挂... 绝活儿透视挂!中至余干可以装挂(辅助)其实真的是有辅助脚本(哔哩哔哩)1)中至余干可以装挂辅助插件:...
两分钟外挂透视!we-poke... 两分钟外挂透视!we-poker软件,wepoker私人定制透视(真实有挂)-哔哩哔哩暗藏猫腻,小编...
秘籍透视挂!菠萝辅助器1.3(... 秘籍透视挂!菠萝辅助器1.3(辅助)总是是真的有辅助工具(哔哩哔哩)1、菠萝辅助器1.3辅助软件下载...
9分钟外挂透视!wepoker... 9分钟外挂透视!wepoker怎么拿到好牌,德扑之心免费透视(真是有挂)-哔哩哔哩1、上手简单,内置...
经验透视挂!点星休闲辅助器下载... 经验透视挂!点星休闲辅助器下载(辅助)一直真的是有辅助攻略(哔哩哔哩)1、打开软件启动之后找到中间准...
第八分钟外挂透视!wpk俱乐部... 第八分钟外挂透视!wpk俱乐部怎么透视挂,aapoker插件(了解有挂)-哔哩哔哩wpk俱乐部怎么透...
学习透视挂!哈糖大菠萝提高胜率... 学习透视挂!哈糖大菠萝提高胜率(辅助)原来一直总是有辅助工具(哔哩哔哩)哈糖大菠萝提高胜率是不是有人...
9分钟外挂透视!wepoker... 9分钟外挂透视!wepoker智能辅助插件,wepoker智能辅助插件(有人有挂)-哔哩哔哩在进入w...
第4分钟外挂透视!德普之星透视... 第4分钟外挂透视!德普之星透视辅助软件激活码,wepoker到底有没有透视(有挂神器)-哔哩哔哩1、...
妙计透视挂!禅游指尖四川修改器... 妙计透视挂!禅游指尖四川修改器(辅助)原来是真的有辅助技巧(哔哩哔哩)1、许多玩家不知道禅游指尖四川...