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、红龙扑克辅助器!红龙扑克辅助器(红龙扑克)好像存在有挂(详细辅助教程);详细教程。2、透视辅助简...
黑科技辅助挂!Wepoke一直... 黑科技辅助挂!Wepoke一直真的是有挂,Wepoke必胜都是真的有挂(详细计算辅助教程)1、ai机...
透视辅助!WpK透视辅助教程,... 透视辅助!WpK透视辅助教程,WPK透视本来是有挂(详细外卦挂教程)1、用户打开应用后不用登录就可以...
wepoke辅助机器人!wEP... wepoke辅助机器人!wEPOKE本来真的有挂,德州ai辅助神器wpk(详细透视辅助神器教程)1)...
德扑之星辅助器购买(德扑之星实... 德扑之星辅助器购买(德扑之星实战)辅助软件(辅助挂)一直是真的有挂(详细有作弊教程)1、起透看视 德...
黑科技透明挂!WEPoke辅助... 黑科技透明挂!WEPoke辅助工具,wepoke模拟器一贯有挂(详细ai代打教程)1、黑科技透明挂!...
透视辅助!红龙扑克辅助软件,红... 透视辅助!红龙扑克辅助软件,红龙扑克确实存在有挂(详细辅助教程)运辅助工具,进入游戏界面。进入辅助器...
wepoke有辅助挂!poke... wepoke有辅助挂!pokerworld真是存在有挂,wepower有外挂(详细ai代打辅助插件教...
aapoker透视辅助(aap... aapoker透视辅助(aapoker猫腻)aapoker 辅助工具(辅助挂)都是是有挂(详细辅助教...
透视辅助!AAPOKEr软件透... 透视辅助!AAPOKEr软件透明挂,aapoker有挂竟然是真的有挂(详细猫腻教程)1、aapoke...