Пока я пытался создать Store в реакции-избыточности, я получаю эту странную ошибку.Я не знаю, почему, как я делал это раньше, в другом приложении там все работало нормально.
TypeError: Object(...) is not a function
./src/index.js
C:/projects/facebook/facebook-react/src/index.js:14
11 | import rootReducer from './rootReducer';
12 | import registerServiceWorker from './registerServiceWorker';
13 |
> 14 | const store = createStore(
15 | rootReducer,
16 | composeWithDevtools(applyMiddleware(thunk))
17 | );
View compiled
▶ 6 stack frames were collapsed.
это мой файл
index.js
import { createStore, applyMiddleware} from 'redux';
import { composeWithDevtools } from 'redux-devtools-extension';
import thunk from 'redux-thunk';
import { Provider } from 'react-redux';
import App from './App';
import rootReducer from './rootReducer';
import registerServiceWorker from './registerServiceWorker';
const store = createStore(
rootReducer,
composeWithDevtools(applyMiddleware(thunk))
);
ReactDOM.render(
<BrowserRouter>
<Provider store={store}>
<App />
</Provider>
</BrowserRouter>
, document.getElementById('root'));
registerServiceWorker();
rootReducer
import { combineReducers } from 'redux'; import user from './reducers/user';
export default combineReducers({
user });
редуктор / пользователь
import { USER_LOGGED_IN } from '../types';
export default function user(state = {}, action={}) {
switch (action.type) {
case USER_LOGGED_IN:
return action.user;
default:
return state;
} }