Skip to content

Commit

Permalink
Sharing: Map subset of state tree in connect mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Nov 23, 2015
1 parent e634b81 commit 7102a9a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions client/post-editor/editor-sharing/container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ import EditorSharingAccordion from './accordion';

class EditorSharingContainer extends Component {
constructor( props ) {
const { site, state } = props;

super( props );

// Trigger connection fetch
if ( ! hasFetchedConnections( state, site.ID ) ) {
if ( ! this.props.hasFetchedConnections ) {
this.fetchConnections();
}

Expand Down Expand Up @@ -52,9 +50,8 @@ class EditorSharingContainer extends Component {
}

render() {
const { site, state } = this.props;
const { site, connections } = this.props;
const { post, isNew } = this.state;
const connections = getConnectionsBySiteId( state, site.ID );

return (
<EditorSharingAccordion
Expand All @@ -70,12 +67,16 @@ class EditorSharingContainer extends Component {

EditorSharingContainer.propTypes = {
site: PropTypes.object.isRequired,
state: PropTypes.object.isRequired,
dispatch: PropTypes.func.isRequired
dispatch: PropTypes.func.isRequired,
hasFetchedConnections: PropTypes.bool,
connections: PropTypes.array
};

export default connect(
( state ) => {
return { state };
( state, props ) => {
return {
hasFetchedConnections: hasFetchedConnections( state, props.site.ID ),
connections: getConnectionsBySiteId( state, props.site.ID )
};
}
)( EditorSharingContainer );

0 comments on commit 7102a9a

Please sign in to comment.