Skip to content

Commit

Permalink
Avoid re-renders when the current post changes
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbachhuber committed May 2, 2018
1 parent 67f0f9b commit 3e591c5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions editor/components/post-sticky/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { get } from 'lodash';
import { compose } from '@wordpress/element';
import { withSelect } from '@wordpress/data';

export function PostStickyCheck( { post, postType, children } ) {
export function PostStickyCheck( { hasStickyAction, postType, children } ) {
if (
postType !== 'post' ||
! get( post, [ '_links', 'wp:action-sticky' ], false )
! hasStickyAction
) {
return null;
}
Expand All @@ -22,8 +22,9 @@ export function PostStickyCheck( { post, postType, children } ) {

export default compose( [
withSelect( ( select ) => {
const post = select( 'core/editor' ).getCurrentPost();
return {
post: select( 'core/editor' ).getCurrentPost(),
hasStickyAction: get( post, [ '_links', 'wp:action-sticky' ], false ),
postType: select( 'core/editor' ).getCurrentPostType(),
};
} ),
Expand Down

0 comments on commit 3e591c5

Please sign in to comment.