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

相关内容

热门资讯

黑科技计算!德州ai机器人,太... 黑科技计算!德州ai机器人,太嚣张了都是有挂(透视)德州教程(2020已更新)(哔哩哔哩)1)德州a...
黑科技AI(德扑ai)外挂透明... 黑科技AI(德扑ai)外挂透明挂黑科技辅助工具(透视)必备教程(2022已更新)(哔哩哔哩);黑科技...
黑科技代打(wepoke挂)外... 黑科技代打(wepoke挂)外挂透明挂辅助神器(透视)新2025版(2023已更新)(哔哩哔哩)1、...
黑科技ai!智星德州菠萝外挂,... 黑科技ai!智星德州菠萝外挂,太离谱了本来存在有挂(透视)攻略方法(2020已更新)(哔哩哔哩)1、...
黑科技AI(智星德州菠萝)外挂... 黑科技AI(智星德州菠萝)外挂透明挂黑科技辅助插件(透视)力荐教程(2020已更新)(哔哩哔哩)1、...
黑科技了解(欢乐棋牌)外挂透明... 黑科技了解(欢乐棋牌)外挂透明挂辅助app(透视)存在挂教程(2023已更新)(哔哩哔哩)1、欢乐棋...
黑科技辅助!德州免费辅助神器a... 黑科技辅助!德州免费辅助神器app,太离谱了原来是有挂(透视)黑科技教程(2020已更新)(哔哩哔哩...
黑科技AI(wpk游戏)外挂透... 黑科技AI(wpk游戏)外挂透明挂黑科技辅助插件(透视)必胜教程(2026已更新)(哔哩哔哩)是一款...
黑科技神器(轰趴大菠萝)外挂透... 黑科技神器(轰趴大菠萝)外挂透明挂辅助器(透视)透明挂教程(2021已更新)(哔哩哔哩)所有人都在同...
黑科技私人局!wpk辅助外挂,... 黑科技私人局!wpk辅助外挂,太夸张了一贯是有挂(透视)分享教程(2020已更新)(哔哩哔哩)1、完...