Skip to content

Commit

Permalink
Sharing: Allow and guard against empty site
Browse files Browse the repository at this point in the history
Can occur when navigating from a site-specific page to a
non-site-specific page, during which time the selected site is unset
while the component is still mounted.
  • Loading branch information
aduth committed Nov 24, 2015
1 parent 1220fa3 commit c97533c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions client/post-editor/editor-sharing/container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ class EditorSharingContainer extends Component {

fetchConnections() {
const { site, dispatch } = this.props;
if ( ! site ) {
return;
}

dispatch( fetchConnections( site.ID ) );
}

Expand All @@ -76,7 +80,7 @@ class EditorSharingContainer extends Component {
}

EditorSharingContainer.propTypes = {
site: PropTypes.object.isRequired,
site: PropTypes.object,
dispatch: PropTypes.func.isRequired,
hasFetchedConnections: PropTypes.bool,
connections: PropTypes.array
Expand All @@ -85,8 +89,8 @@ EditorSharingContainer.propTypes = {
export default connect(
( state, props ) => {
return {
hasFetchedConnections: hasFetchedConnections( state, props.site.ID ),
connections: getConnectionsBySiteId( state, props.site.ID )
hasFetchedConnections: props.site && hasFetchedConnections( state, props.site.ID ),
connections: props.site ? getConnectionsBySiteId( state, props.site.ID ) : null
};
}
)( EditorSharingContainer );

0 comments on commit c97533c

Please sign in to comment.