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

相关内容

热门资讯

热点推荐!微信小程序途游辅助免... 热点推荐!微信小程序途游辅助免费,有哪些免费的wpk作弊码,细节揭秘(有挂技巧)-哔哩哔哩是一款可以...
重大消息!互游辅助脚本,哈糖大... 重大消息!互游辅助脚本,哈糖大菠萝怎么开挂,德州教程(有挂助手)-哔哩哔哩;互游辅助脚本简单的灵活控...
推荐一下!福建天天开心辅助真实... 推荐一下!福建天天开心辅助真实性,黑桃a3辅助,一贯有挂(哔哩哔哩)1、起透看视 福建天天开心辅助真...
今日焦点!腾讯欢乐卡五星辅助器... 今日焦点!腾讯欢乐卡五星辅助器,wepoker怎么下载游戏,力荐教程(真是有挂)-哔哩哔哩;亲,有的...
解谜一下!大宝苏北麻将怎么开挂... 解谜一下!大宝苏北麻将怎么开挂,开心游戏快跑辅助,其实存在有挂(哔哩哔哩)大宝苏北麻将怎么开挂能透视...
一分钟揭秘!边锋老友杰克辅助,... 一分钟揭秘!边锋老友杰克辅助,wepoker私人局俱乐部怎么进,插件教程(新版有挂)-哔哩哔哩;AI...
详情一下!九九山城辅助免费,浙... 详情一下!九九山城辅助免费,浙江宝宝游戏辅助工具,一贯存在有挂(哔哩哔哩)1、下载好九九山城辅助免费...
玩家必看教程!白金岛跑胡子脚本... 玩家必看教程!白金岛跑胡子脚本,微扑克游戏辅助器,科技教程(有挂秘诀)-哔哩哔哩;白金岛跑胡子脚本最...
有挂一下!老友广东潮汕麻雀,山... 有挂一下!老友广东潮汕麻雀,山西扣点带你辅助工具破解,都是是有挂(哔哩哔哩)1、老友广东潮汕麻雀模拟...
今日重大通报!花舍辅助,wep... 今日重大通报!花舍辅助,wepoker软件靠谱么,必备教程(有挂方式)-哔哩哔哩;1、不需要AI权限...