【发布时间】:2018-11-12 20:22:54
【问题描述】:
我绝对是 React Native、Redux 和朋友的初学者。
现在我尝试使用 React Native 和 Redux 创建一个应用程序。
在这个过程中我发现了这个错误:
我尝试像这样在我的应用程序中使用 Redux:
export const confirmRegister = (userdata) => {
return (dispatch) => {
return(
fetch(URI + path, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'x-application-id' : AppId,
'hashing' : this.generateHashing(userdata)
},
body: userdata,
})
.then((response) => {
return response.json()
})
.then((response)=>{
dispatch(setDataAfterRegister(response.result))
})
.catch(error => {alert(error)})
)
};
};
export function setDataAfterRegister(data){
return{
type:'REGISTERED',
name:data.name,
token:data.access_token
}
}
我还在学习如何使用 Redux。
任何帮助将不胜感激。
这是我的商店:
import { createStore } from 'redux';
import rootReducer from './reducers';
let store = createStore(rootReducer);
export default store;
【问题讨论】:
-
你设置 redux-thunk 了吗?
-
不,我的应用中没有 redux-thunk
-
展示你如何创建你的 redux 存储。
标签: reactjs react-native redux