Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

fix: as forwarder issue #428

Merged
merged 1 commit into from
Sep 13, 2023
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
17 changes: 14 additions & 3 deletions packages/react/src/AsForwarder.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import React from 'react';
import Svg from 'react-native-svg';
import type { ViewProps } from 'react-native';

const AsForwarder = ({ as, children, ...props }: any) => {
export interface InterfaceAsForwardedProps extends ViewProps {
as?: any;
}

const AsForwarderTemp = ({
as,
children,
...props
}: any): React.ReactElement => {
const As: any = as;
return as ? <As {...props}>{children}</As> : <Svg {...props}>{children}</Svg>;
};
AsForwarder.displayName = '__AsForwarder__';
export { AsForwarder };
AsForwarderTemp.displayName = '__AsForwarder__';

export const AsForwarder =
AsForwarderTemp as React.ComponentType<InterfaceAsForwardedProps>;