[英]Provider.js:20 Uncaught TypeError: store.getState is not a function
**I cant fixt this error, please help me to fix it. **我无法修复此错误,请帮助我修复它。 when I am going to run my reactApp into my local-host then in the console I get lot o error but my terminal does not get any error.当我要将我的 reactApp 运行到我的本地主机中时,然后在控制台中我收到很多错误,但我的终端没有收到任何错误。 In this App I am using redux,react-redux,axios,thunk from packegemanager **在这个应用程序中,我使用 redux,react-redux,axios,来自packegemanager **
here is my code这是我的代码
index.js index.js
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import { Provider } from 'react-redux';
import store from './store'
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<Provider store={store}>
<App />
</Provider>
</React.StrictMode>
);
App.js应用程序.js
function App() {
return (
<div className="App">
<h3>Practice redux</h3>
<TodosApp />
</div>
);
}
export default App;
store.js store.js
import todosReducer from './component/todo/todoReducer'
import thunk from 'redux-thunk'
const store = createStore(todosReducer,thunk)
export default store
actiontype.js actiontype.js
export const GET_REQUEST_SUCCESS = 'GET_REQUEST_SUCCESS'
export const GET_REQUEST_FAILD = 'GET_REQUEST_FAILD'
actionCreator.js actionCreator.js
const initialState = {
isLoading : false,
todo :[],
error: null
}
const todosReducer = (state= initialState,action) => {
switch (action.type) {
case GET_REQUEST_LOADING:
return{
...state,
isLoading:true
}
case GET_REQUEST_SUCCESS:
return{
...state,
todo : action.payload,
isLoading :false,
error: null
}
case GET_REQUEST_FAILD:
return{
...state,
error: action.payload
}
default:
return state;
}
}
export default todosReducer
todoReducer todoreducer
const initialState = {
isLoading : false,
todo :[],
error: null
}
const todosReducer = (state= initialState,action) => {
switch (action.type) {
case GET_REQUEST_LOADING:
return{
...state,
isLoading:true
}
case GET_REQUEST_SUCCESS:
return{
...state,
todo : action.payload,
isLoading :false,
error: null
}
case GET_REQUEST_FAILD:
return{
...state,
error: action.payload
}
default:
return state;
}
}
export default todosReducer
import { createStore, applyMiddleware } from 'redux';从'redux'导入{createStore,applyMiddleware};
export const store = createStore(countReducer, applyMiddleware(thunk)); export const store = createStore(countReducer, applyMiddleware(thunk)); thunk should go through middleware. thunk 应该 go 通过中间件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.