Skip to content

Commit

Permalink
move Optional component to TS
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidsector9 committed Mar 1, 2024
1 parent b1968f5 commit a3485d0
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import PropTypes from 'prop-types';
import { useBlockEditContext } from '@wordpress/block-editor';

export const Optional = ({ value, children }) => {
interface OptionalProps {
value?: string|number|boolean;
children: React.ReactNode;
}

export const Optional: React.FC<OptionalProps> = ({ value, children }): boolean | React.ReactNode => {
const { isSelected } = useBlockEditContext();
return (isSelected || !!value) && children;
};
Expand Down

0 comments on commit a3485d0

Please sign in to comment.