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

相关内容

热门资讯

近期!大菠萝手游辅助(透视)确... 您好,大菠萝手游辅助这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多玩家...
辅助透视!德普之星的辅助工具介... 辅助透视!德普之星的辅助工具介绍!重大消息辅助工具(有挂详情)-哔哩哔哩德普之星的辅助工具介绍破解侠...
随着!wepoker辅助器官方... 随着!wepoker辅助器官方(透视)切实是有辅助安装(有挂分析)-哔哩哔哩;1、用户打开应用后不用...
必备透视!wepoker辅助软... 必备透视!wepoker辅助软件视频!热点推荐辅助器(真的有挂)-哔哩哔哩1、必备透视!wepoke...
透视辅助!wepoker插件辅... 透视辅助!wepoker插件辅助(透视)总是有辅助插件(有挂方法)-哔哩哔哩1、wepoker插件辅...
揭幕透视!菠萝辅助器免费版的特... 揭幕透视!菠萝辅助器免费版的特点!新手必备辅助工具(有挂分享)-哔哩哔哩1、很好的工具软件,可以解锁...
透视存在!wepoker亲友圈... 透视存在!wepoker亲友圈有用吗(透视)其实存在有辅助神器(有挂功能)-哔哩哔哩1、wepoke...
开挂透视!wepoker手机版... 开挂透视!wepoker手机版辅助!必备攻略辅助挂(的确有挂)-哔哩哔哩wepoker手机版辅助辅助...
透视神器!德普之星辅助工具如何... 透视神器!德普之星辅助工具如何设置(透视)一直真的有辅助修改器(有挂功能)-哔哩哔哩1、该软件可以轻...
曝光透视!wepoker免费脚... 曝光透视!wepoker免费脚本咨询!每日必备辅助挂(有挂规律)-哔哩哔哩一、wepoker免费脚本...