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秒钟知晓!家乡大二辅助,小程... 1秒钟知晓!家乡大二辅助,小程序牵手跑得有辅助吗(有挂开挂辅助插件);无需打开直接搜索加(薇:136...
透视实锤!广西微乐小程序脚本,... 透视实锤!广西微乐小程序脚本,wepoker免费脚本弱密码,必胜教程(有挂开挂辅助插件)1、下载安装...
第八方案!微乐陕西小程序脚本,... 第八方案!微乐陕西小程序脚本,新星游辅助软件免费版(有挂开挂辅助挂);无需打开直接搜索加(薇:136...
玩家必看秘籍!新道游游戏辅助器... 玩家必看秘籍!新道游游戏辅助器免费版,创思维辅助器(有挂开挂辅助脚本);无需打开直接搜索打开薇:13...
十分钟领会!潇湘游有挂脚本,青... 十分钟领会!潇湘游有挂脚本,青鸟辅助器(有挂开挂辅助神器);无需打开直接搜索加(薇:13670430...
透视计算!天酷大厅辅助,微乐小... 透视计算!天酷大厅辅助,微乐小程序有脚本吗,详细教程(有挂开挂辅助神器);无需打开直接搜索加薇136...
第一操作!樱花之盛辅助真的假的... 第一操作!樱花之盛辅助真的假的,新挑战辅助脚本(有挂开挂辅助软件);无需打开直接搜索打开薇:1367...
交流学习经验!四川辅助软件,微... 交流学习经验!四川辅助软件,微信卡五星辅助(有挂开挂辅助工具);无需打开直接搜索打开薇:136704...
第九小时掌握!蛮王大厅辅助,一... 第九小时掌握!蛮王大厅辅助,一起宁德钓蟹技巧(有挂开挂辅助挂)1、下载安装好一起宁德钓蟹技巧,进入游...