【发布时间】:2021-10-29 10:55:22
【问题描述】:
在我的Register.tsx 文件中,我有以下代码:
<View style={styles.keyboardView}>
<Formik
initialValues={{
firstname: '',
lastname: '',
email: '',
password: '',
}}
onSubmit={values => {
dispatch(authAction.registerUser(values))
.then(() => {
navigateTo('HomeScreen');
})
.catch(err => console.log(err));
}}
validationSchema={RegisterValidationSchema}>
Visual Studio 代码突出显示 .then(),错误为:Property 'then' does not exist on type '(dispatch: any) => Promise<void>'.ts(2339)
此外,err 也在 Visual Studio 代码中显示此错误:Parameter 'err' implicitly has an 'any' type.ts(7006)
这是我的store.js 代码的样子:
import {createStore, applyMiddleware, combineReducers} from 'redux';
import thunk from 'redux-thunk';
import {composeWithDevTools} from 'redux-devtools-extension';
import authReducer from './reducers/authReducer';
const rootReducer = combineReducers({
auth: authReducer,
});
const middleware = composeWithDevTools(applyMiddleware(thunk));
const store = createStore(rootReducer, middleware);
export default store;
请注意,我使用的是.js 文件而不是.tsx 文件。所以我混合了两个文件。这会导致问题吗?
我该如何解决这个问题?
【问题讨论】:
标签: reactjs react-native redux react-redux