Skip to content

Commit

Permalink
CardMedia: refactor away from the createComponent function (#34915)
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo authored Sep 19, 2021
1 parent fcc32ee commit 55ed542
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions packages/components/src/card/card-media/component.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
/**
* Internal dependencies
*/
import { createComponent } from '../../ui/utils';
import { contextConnect } from '../../ui/context';
import { View } from '../../view';
import { useCardMedia } from './hook';

/**
* @param {import('../../ui/context').WordPressComponentProps<{ children: import('react').ReactNode }, 'div'>} props
* @param {import('react').Ref<any>} forwardedRef
*/
function CardMedia( props, forwardedRef ) {
const cardMediaProps = useCardMedia( props );

return <View { ...cardMediaProps } ref={ forwardedRef } />;
}

/**
* `CardMedia` provides a container for media elements within a `Card`.
*
Expand All @@ -21,10 +32,6 @@ import { useCardMedia } from './hook';
* );
* ```
*/
const CardMedia = createComponent( {
as: 'div',
useHook: useCardMedia,
name: 'CardMedia',
} );
const ConnectedCardMedia = contextConnect( CardMedia, 'CardMedia' );

export default CardMedia;
export default ConnectedCardMedia;

0 comments on commit 55ed542

Please sign in to comment.