Добрый день помогите решить проблему 3 день ломаю голову выдает ошибку на undefined store
index.js
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import App from './App';
import store from "./redux/store-redux"
import reportWebVitals from './reportWebVitals';
let rerenderEntrieTree = (store) => {
ReactDOM.render(
<React.StrictMode>
<Provider store ={store}>
<App />
</Provider>
</React.StrictMode>,
document.getElementById('root')
);
}
rerenderEntrieTree();
store.subscribe( () => {
rerenderEntrieTree()
});
reportWebVitals();
MyPostContainer.js
import { connect } from 'react-redux';
import { addPostCreateAction, updatePostTextCreateAction } from '../../../redux/profile-reducer';
import MyPost from './MyPost';
let mapStateToProps = (store) => {
return {
newPostText: store.newPostText,
post: store.post
}
}
let mapDispatchToProps = (dispatch) => {
return {
addPost: () => {
dispatch(addPostCreateAction());
},
onPostChange: (text) => {
let action = updatePostTextCreateAction(text)
dispatch(action);
}
}
}
const MyPostContainer = () => connect(mapDispatchToProps, mapStateToProps)(MyPost);
xport default MyPostContainer;
redux-store.js
import { combineReducers, createStore } from "redux";
import dialogsReducer from "./dialogs-reducer";
import profileRuducer from "./profile-reducer";
import sidebarReducer from "./sidebar-reducer";
export let redusers = combineReducers({
profilePage:profileRuducer,
dialogsPage:dialogsReducer,
sidebarPage:sidebarReducer
});
let store = createStore(redusers);
export default store;
dialogs-reducers.js
const sendMessageText = "SEND-MESSAGE-TEXT";
const changeMessageText = "CHANGE-MESSAGE-TEXT";
let initialState = {
dialog: [
{ id: 1, name: "Alex" },
{ id: 2, name: "Dasha" },
{ id: 3, name: "Oleg" },
{ id: 4, name: "Tamara" },
{ id: 5, name: "Igor" },
{ id: 6, name: "Lisa" },
],
messages: [
{ message: "Hi", id: 1 },
{ message: "my", id: 2 },
{ message: "name", id: 3 },
{ message: "is", id: 4 },
{ message: "Alex", id: 5 },
{ message: "Yo", id: 6 }
],
newMessageBody: "",
};
const dialogsReducer = (state = initialState, action) => {
switch (action.type) {
case sendMessageText:
let body = state.newMessageBody;
state.messages.push({ message: body, id: 6 });
state.newMessageBody = "";
return state;
case changeMessageText:
state.newMessageBody = action.body;
return state;
default: return state;
}
}
export const changeMessageCreator = (body) =>
({
type: changeMessageText,
body: body,
})
export const sendMessageCreator = () => ({ type: sendMessageText })
export default dialogsReducer;
Provider.js
import React, { useMemo } from 'react';
import PropTypes from 'prop-types';
import { ReactReduxContext } from './Context';
import { createSubscription } from '../utils/Subscription';
import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect';
function Provider(_ref) {
var store = _ref.store,
context = _ref.context,
children = _ref.children;
var contextValue = useMemo(function () {
var subscription = createSubscription(store);
subscription.onStateChange = subscription.notifyNestedSubs;
return {
store: store,
subscription: subscription
};
}, [store]);
var previousState = useMemo(function () {
return store.getState();
}, [store]);
useIsomorphicLayoutEffect(function () {
var subscription = contextValue.subscription;
subscription.trySubscribe();
if (previousState !== store.getState()) {
subscription.notifyNestedSubs();
}
return function () {
subscription.tryUnsubscribe();
subscription.onStateChange = null;
};
}, [contextValue, previousState]);
var Context = context || ReactReduxContext;
return /*#__PURE__*/React.createElement(Context.Provider, {
value: contextValue
}, children);
}
if (process.env.NODE_ENV !== 'production') {
Provider.propTypes = {
store: PropTypes.shape({
subscribe: PropTypes.func.isRequired,
dispatch: PropTypes.func.isRequired,
getState: PropTypes.func.isRequired
}),
context: PropTypes.object,
children: PropTypes.any
};
}
export default Provider;
В провайдере показывает _ref:undefined
Что я делаю не так?