错误:
\nArgument of type \'(dispatch: Dispatch<ShopDispatchTypes>) => Promise<void>\' is not assignable to parameter of type \'AnyAction\'.\nuseEffect(() => {\n dispatch(GetShops());\n}, []);\nRun Code Online (Sandbox Code Playgroud)\n我正在尝试使用 Typescript 实现 redux-thunk。我使用react、typescript和redux-thunk创建了简单的购物卡应用程序,但遇到了上述问题。\n下面是我的代码片段\xe2\x80\x99s。如果您需要更多信息,请随时询问。
\n商店.actionTypes.ts
\nexport const SHOP_LOAD_START = \'SHOP_LOAD_START\';\nexport const SHOP_LOAD_SUCCESS = \'SHOP_LOAD_SUCCESS\';\nexport const SHOP_LOAD_ERROR = \'SHOP_LOAD_ERROR\';\n\nexport type Shop = {\n id: string;\n name: string;\n};\n\nexport type ShopType = {\n shops: Shop[];\n};\n\nexport interface ShopLoadStart {\n type: typeof SHOP_LOAD_START;\n}\n\nexport interface ShopLoadError {\n type: typeof SHOP_LOAD_ERROR;\n}\n\nexport interface ShopLoadSuccess {\n type: typeof SHOP_LOAD_SUCCESS;\n payload: ShopType;\n}\n\nexport type ShopDispatchTypes = ShopLoadStart …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 javascript 实现 crossmint-pay-button 。我正在使用 cdn 链接:https://unpkg.com/@crossmint/client-sdk-vanilla-ui@0.0.1-alpha.1/lib/index.global.js
<crossmint-pay-button
collectionTitle="Gaia comic"
collectionDescription="Gaia comic collection "
collectionPhoto=""
clientId="8d77450f.....ad497f612"
mintConfig='{"type":"erc-721","price":"0.1","_count":"1"}'
environment="staging"
/>
Run Code Online (Sandbox Code Playgroud)
当我单击下面的“付款”按钮时,会出现错误。“缺少铸造所需的参数计数。请在 mintParams 中提供参数”
data我试图在接口中实现常量,但为什么在 switch 情况下访问时会出错?
如果我只使用stringininterface而不是常量,APP_STATUS那么它就可以正常工作。
例子:
// Gives an error
interface InconsistenciesData {
type: typeof APP_STATUS.INCONSISTENCIES;
data: Inconsistency[];
}
// Works fine
interface InconsistenciesData {
type: 'INCONSISTENCIES';
data: Inconsistency[];
}
Run Code Online (Sandbox Code Playgroud)
下面是我的代码片段。
export const APP_STATUS = {
CONFIRMED: 'CONFIRMED',
INCONSISTENCIES: 'INCONSISTENCIES',
SUCCESS: 'SUCCESS',
ERROR: 'ERROR',
LOADING: 'LOADING',
OK: 'OK'
}
interface InconsistenciesLoading {
type: typeof APP_STATUS.LOADING;
}
interface InconsistenciesError {
type: typeof APP_STATUS.ERROR;
}
interface InconsistenciesSuccess {
type: typeof APP_STATUS.SUCCESS;
}
interface InconsistenciesData …Run Code Online (Sandbox Code Playgroud) typescript ×2
crossmint ×1
interface ×1
nft ×1
react-redux ×1
reactjs ×1
redux ×1
redux-thunk ×1