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透视辅助方法,... 脚本解密!wpk透视辅助方法,有哪些免费的wpk作必弊码(透视)真是是真的app(哔哩哔哩);1、上...
脚本解谜!hhpoker软件安... 脚本解谜!hhpoker软件安装包,hhpoker视频巡查真的假的(透视)一直真的是有插件(哔哩哔哩...
脚本分享!wpk显示有作必弊,... 脚本分享!wpk显示有作必弊,wpk俱乐部辅助器(透视)总是真的有软件(哔哩哔哩)1、让任何用户在无...
透视关于!wepoker怎么拿... 透视关于!wepoker怎么拿到好牌,wepokerplus辅助(透视)确实真的是有app(哔哩哔哩...
透视详情!hhpoker怎么破... 透视详情!hhpoker怎么破解,hhpoker底牌透视脚本(透视)总是真的有技巧(哔哩哔哩)1、实...
脚本透视!aapoker脚本,... 脚本透视!aapoker脚本,aapoker如何设置胜率(透视)总是是有技巧(哔哩哔哩)小薇(辅助器...
脚本详情!德普之星辅助工具如何... 脚本详情!德普之星辅助工具如何设置,德普之星辅助工具如何打开(透视)总是真的是有脚本(哔哩哔哩)脚本...
透视推荐!wpk官网下载链接,... 透视推荐!wpk官网下载链接,wpk透视辅助(透视)都是是真的教程(哔哩哔哩)1、超多福利:超高返利...
脚本详情!wpk辅助器,wpk... 脚本详情!wpk辅助器,wpk德州局怎么透视(透视)好像是真的软件(哔哩哔哩)1、德州局怎么透视破解...
透视分享!wejoker透视方... 透视分享!wejoker透视方法,wepoker黑侠辅助器(透视)都是真的有脚本(哔哩哔哩)1、用户...