Skip to content

Commit

Permalink
add TS support for PostTitle component
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidsector9 committed Mar 3, 2024
1 parent 049be1a commit e903d32
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions components/post-title/index.js → components/post-title/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import { useEntityProp } from '@wordpress/core-data';
import { RichText, store as blockEditorStore } from '@wordpress/block-editor';
import { useSelect } from '@wordpress/data';
import PropTypes from 'prop-types';
import { usePost } from '../../hooks';

export const PostTitle = (props) => {
const { tagName: TagName = 'h1', ...rest } = props;
interface PostTitleProps {
/**
* The HTML tag name to use for the title.
*/
tagName?: keyof JSX.IntrinsicElements;

/**
* Additional props to pass to the title element.
*/
[key: string]: any;
}

export const PostTitle: React.FC<PostTitleProps> = ( { tagName: TagName = 'h1', ...rest } ) => {
const { postId, postType, isEditable } = usePost();

const [rawTitle = '', setTitle, fullTitle] = useEntityProp(
Expand Down Expand Up @@ -37,10 +47,6 @@ export const PostTitle = (props) => {
);
};

PostTitle.propTypes = {
tagName: PropTypes.string,
};

PostTitle.defaultProps = {
tagName: 'h1',
};

0 comments on commit e903d32

Please sign in to comment.