Skip to content

Commit

Permalink
fix: withChild
Browse files Browse the repository at this point in the history
  • Loading branch information
headfire94 committed Oct 18, 2024
1 parent b83ca62 commit fc11393
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type StyledComponent<P extends object, S extends object> = React.ForwardR
extend: <SP extends object>(more: ComponentStyle<P, SP, S>) => StyledComponent<P & SP, S>;
attrs: (attrs: any) => StyledComponent<P, S>;
withComponent: (comp: React.ComponentType<any>) => StyledComponent<P, S>;
withChild: (child: React.ComponentType<any>, childProps: any) => StyledComponent<P, S>;
withChild: (child: React.ComponentType<any>, childProps?: any) => StyledComponent<P, S>;
};

type ComponentFactory<P extends object, S extends object> = <SP extends object>(
Expand Down
4 changes: 3 additions & 1 deletion test/index.type-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const StyledImageWithDynamicProps = extendedStyled.Image((props: {active: boolea

const StyledTouchable = extendedStyled.Touchable({width: 100})
const StyledTouchableWithDynamicProps = extendedStyled.Image((props: {active: boolean}) => ({width: props.active ? 100 : 50}))

const ViewWithText = extendedStyled.View({}).withChild(StyledText)

const MyScreen = () => {
return (
Expand Down Expand Up @@ -61,6 +61,8 @@ const MyScreen = () => {

<StyledTouchable>Touchable</StyledTouchable>
<StyledTouchableWithDynamicProps active>Touchable with dynamic style</StyledTouchableWithDynamicProps>

<ViewWithText />
</>
)
}

0 comments on commit fc11393

Please sign in to comment.