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

相关内容

热门资讯

第二分钟黑科技!wepoker... 第二分钟黑科技!wepoker底牌透视脚本下载,we poker插件(透视)线上教程(有人有挂)1、...
2分钟细说!德州扑克微扑克俱乐... 2分钟细说!德州扑克微扑克俱乐部,德州ai辅助软件推荐,教你攻略(有挂详情)-哔哩哔哩;一、德州扑克...
第8分钟精通!wepoker透... 第8分钟精通!wepoker透视脚本苹果版,菠萝德州透视脚本(透视)力荐教程(有挂细节)1、很好的工...
科普分享!德州之星app有外挂... 科普分享!德州之星app有外挂,德州ai智能系统,专业教程(有挂工具)-哔哩哔哩;德州之星app有外...
6分钟普及!hhpoker到底... 6分钟普及!hhpoker到底可以透视挂码,hhpoker辅助软件(透视)技巧教程(有挂技巧)1、h...
今日科普!aapoker有可以... 今日科普!aapoker有可以规律,wepower记牌器,靠谱教程(有挂规律)-哔哩哔哩;aapok...
第七分钟熟悉!菠萝德普辅助器免... 第七分钟熟悉!菠萝德普辅助器免费版在哪里,wepoker轻量版透视(透视)黑科技教程(有挂讲解)第七...
玩家爆料!wepower有ai... 玩家爆料!wepower有ai,wpk辅助,必胜教程(有挂技巧)-哔哩哔哩;1、让任何用户在无需AI...
6分钟领会!pokernow辅... 6分钟领会!pokernow辅助控制,wepoker辅助器免费(透视)解说技巧(有挂规律)wepok...
揭秘攻略!aapoker透明挂... 揭秘攻略!aapoker透明挂辅助器,德扑之星有系统新手保护期,细节方法(有挂详情)-哔哩哔哩;详细...