Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
VStack: refactor away from the createComponent function
  • Loading branch information
ciampo committed Sep 9, 2021
commit 46585334a39829f4a536cf60d7e1504e0876d06f
21 changes: 14 additions & 7 deletions packages/components/src/v-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 { useVStack } from './hook';

/**
* @param {import('../ui/context').PolymorphicComponentProps<import('./types').Props, 'div'>} props
* @param {import('react').Ref<any>} forwardedRef
*/
function VStack( props, forwardedRef ) {
const vStackProps = useVStack( props );

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

/**
* `VStack` (or Vertical Stack) is a layout component that arranges child elements in a vertical line.
*
Expand All @@ -27,10 +38,6 @@ import { useVStack } from './hook';
* }
* ```
*/
const VStack = createComponent( {
as: 'div',
useHook: useVStack,
name: 'VStack',
} );
const ConnectedVStack = contextConnect( VStack, 'VStack' );

export default VStack;
export default ConnectedVStack;