|
@@ -1,35 +1,57 @@
|
|
|
-import React from 'react';
|
|
|
+// import React from 'react';
|
|
|
import './myPosts.css';
|
|
|
import { addPostActionCreator, updateNewPostTextActionCreator } from '../../../Redux/profile-reducer';
|
|
|
import MyPosts from './myPosts';
|
|
|
-import StoreContext from '../../../StoreContext';
|
|
|
-
|
|
|
-function MyPostsContainer() {
|
|
|
- return (
|
|
|
- <StoreContext.Consumer>
|
|
|
- {
|
|
|
- (store) => {
|
|
|
- let state = store.getState();
|
|
|
-
|
|
|
- let addPost = () => {
|
|
|
- store.dispatch(addPostActionCreator());
|
|
|
- }
|
|
|
-
|
|
|
- let onPostChange = (text) => {
|
|
|
- let action = updateNewPostTextActionCreator(text);
|
|
|
- store.dispatch(action);
|
|
|
- }
|
|
|
-
|
|
|
- return (
|
|
|
- <MyPosts updateNewPostText={onPostChange} addPost={addPost}
|
|
|
- post={state.profilePage.post}
|
|
|
- newPostText={state.profilePage.newPostText}
|
|
|
- />
|
|
|
- )
|
|
|
- }
|
|
|
- }
|
|
|
- </StoreContext.Consumer>
|
|
|
- )
|
|
|
+// import StoreContext from '../../../StoreContext';
|
|
|
+import { connect } from 'react-redux';
|
|
|
+
|
|
|
+// function MyPostsContainer() {
|
|
|
+// return (
|
|
|
+// <StoreContext.Consumer>
|
|
|
+// {
|
|
|
+// (store) => {
|
|
|
+// let state = store.getState();
|
|
|
+
|
|
|
+// let addPost = () => {
|
|
|
+// store.dispatch(addPostActionCreator());
|
|
|
+// }
|
|
|
+
|
|
|
+// let onPostChange = (text) => {
|
|
|
+// let action = updateNewPostTextActionCreator(text);
|
|
|
+// store.dispatch(action);
|
|
|
+// }
|
|
|
+
|
|
|
+// return (
|
|
|
+// <MyPosts updateNewPostText={onPostChange} addPost={addPost}
|
|
|
+// post={state.profilePage.post}
|
|
|
+// newPostText={state.profilePage.newPostText}
|
|
|
+// />
|
|
|
+// )
|
|
|
+// }
|
|
|
+// }
|
|
|
+// </StoreContext.Consumer>
|
|
|
+// )
|
|
|
+// }
|
|
|
+
|
|
|
+const mapStateToProps = (state) => {
|
|
|
+ return {
|
|
|
+ post: state.profilePage.post,
|
|
|
+ newPostText: state.profilePage.newPostText
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const mapDispatchToProps = (dispatch) => {
|
|
|
+ return {
|
|
|
+ updateNewPostText: (text) => {
|
|
|
+ let action = updateNewPostTextActionCreator(text);
|
|
|
+ dispatch(action);
|
|
|
+ },
|
|
|
+ addPost: () => {
|
|
|
+ dispatch(addPostActionCreator());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+const MyPostsContainer = connect(mapStateToProps, mapDispatchToProps)(MyPosts);
|
|
|
+
|
|
|
export default MyPostsContainer;
|