UNPKG

@wordpress/editor

Version:
44 lines (41 loc) 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = PostStickyCheck; var _data = require("@wordpress/data"); var _store = require("../../store"); /** * WordPress dependencies */ /** * Internal dependencies */ /** * Wrapper component that renders its children only if post has a sticky action. * * @param {Object} props Props. * @param {Element} props.children Children to be rendered. * * @return {Component} The component to be rendered or null if post type is not 'post' or hasStickyAction is false. */ function PostStickyCheck({ children }) { const { hasStickyAction, postType } = (0, _data.useSelect)(select => { var _post$_links$wpActio; const post = select(_store.store).getCurrentPost(); return { hasStickyAction: (_post$_links$wpActio = post._links?.['wp:action-sticky']) !== null && _post$_links$wpActio !== void 0 ? _post$_links$wpActio : false, postType: select(_store.store).getCurrentPostType() }; }, []); if (postType !== 'post' || !hasStickyAction) { return null; } return children; } //# sourceMappingURL=check.js.map