react-native-web icon indicating copy to clipboard operation
react-native-web copied to clipboard

How to use types mentioned inside react native inside react-native-web app ?

Open archana-iron opened this issue 2 years ago • 0 comments

Is there an existing request?

  • [X] I have searched for this request

Describe the feature request

I am building a react js web custom component package where I have to show the preview of my mobile components. So I created a react native components package and later added a clone copy of the package for the react native web app also by using an alias. Now, the problem is I am not able to use the types used inside react native component inside the react native component package. Example:

import React, { memo } from 'react'; import { View as NativeView, type ViewStyle } from 'react-native-web';

export interface ViewProps { children?: React.ReactNode; style?: { style?: ViewStyle; }; }

function View({ children = null, style = {}, ...rest }: ViewProps) { return ( <NativeView style={style?.style} {...rest}> {children} ); }

View.displayName = 'View';

export default memo(View);

Getting error: Unsafe type declaration for 'any', inside <NativeView style={style?.style} {...rest}>, for style?.style. Please suggest how I can use react native types inside the react native web package.

Can we use react native types inside the react native web app or custom package where we have used react native web? If yes, please suggest how.

archana-iron avatar Jun 11 '24 10:06 archana-iron