Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HStack: refactor away from the createComponent function #34920

Merged
merged 1 commit into from
Sep 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions packages/components/src/h-stack/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 { useHStack } from './hook';

/**
* @param {import('../ui/context').WordPressComponentProps<import('./types').Props, 'div'>} props
* @param {import('react').Ref<any>} forwardedRef
*/
function HStack( props, forwardedRef ) {
const hStackProps = useHStack( props );

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

/**
* `HStack` (Horizontal Stack) arranges child elements in a horizontal line.
*
Expand All @@ -27,10 +38,6 @@ import { useHStack } from './hook';
* }
* ```
*/
const HStack = createComponent( {
as: 'div',
useHook: useHStack,
name: 'HStack',
} );
const ConnectedHStack = contextConnect( HStack, 'HStack' );

export default HStack;
export default ConnectedHStack;