Skip to content

Instantly share code, notes, and snippets.

@Sekhmet
Created February 4, 2018 10:36
Show Gist options
  • Save Sekhmet/1ace20856d2b524c7a3295c40d4261cf to your computer and use it in GitHub Desktop.
Save Sekhmet/1ace20856d2b524c7a3295c40d4261cf to your computer and use it in GitHub Desktop.
diff --git a/src/client/feed/SubFeed.js b/src/client/feed/SubFeed.js
index b2fa5705..b0d651f1 100644
--- a/src/client/feed/SubFeed.js
+++ b/src/client/feed/SubFeed.js
@@ -22,8 +22,6 @@ import {
getAuthenticatedUser,
getFeed,
getPosts,
- getShowPostModal,
- getCurrentShownPost,
} from '../reducers';
import Feed from './Feed';
import EmptyFeed from '../statics/EmptyFeed';
@@ -38,8 +36,6 @@ import PostModal from '../post/PostModalContainer';
user: getAuthenticatedUser(state),
feed: getFeed(state),
posts: getPosts(state),
- showPostModalState: getShowPostModal(state),
- currentShownPost: getCurrentShownPost(state),
}),
dispatch => ({
getFeedContent: (sortBy, category) => dispatch(getFeedContent({ sortBy, category, limit: 10 })),
@@ -53,7 +49,6 @@ class SubFeed extends React.Component {
static propTypes = {
authenticated: PropTypes.bool.isRequired,
loaded: PropTypes.bool.isRequired,
- showPostModalState: PropTypes.bool.isRequired,
user: PropTypes.shape().isRequired,
feed: PropTypes.shape().isRequired,
posts: PropTypes.shape().isRequired,
@@ -124,16 +119,7 @@ class SubFeed extends React.Component {
}
render() {
- const {
- authenticated,
- loaded,
- user,
- feed,
- posts,
- match,
- showPostModalState,
- location,
- } = this.props;
+ const { authenticated, loaded, user, feed, posts, match, location } = this.props;
let content = [];
let isFetching = false;
@@ -171,7 +157,7 @@ class SubFeed extends React.Component {
/>
{!content.length && fetched && loaded && <EmptyFeed />}
</div>
- {showPostModalState && <PostModal location={location} />}
+ <PostModal location={location} />
</div>
);
}
diff --git a/src/client/post/PostModalContainer.js b/src/client/post/PostModalContainer.js
index 619fd00e..1325c9c3 100644
--- a/src/client/post/PostModalContainer.js
+++ b/src/client/post/PostModalContainer.js
@@ -1,8 +1,11 @@
+import React from 'react';
import { connect } from 'react-redux';
import { getShowPostModal, getCurrentShownPost } from '../reducers';
import { hidePostModal } from '../app/appActions';
import PostModal from './PostModal';
+const PostModalWrapper = props => props.showPostModal && <PostModal {...props} />;
+
export default connect(
state => ({
showPostModal: getShowPostModal(state),
@@ -11,4 +14,4 @@ export default connect(
{
hidePostModal,
},
-)(PostModal);
+)(PostModalWrapper);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment