Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
172
rated 0 times [  175] [ 3]  / answers: 1 / hits: 7497  / 3 Years ago, tue, january 12, 2021, 12:00:00

Hello guys what should be the type of Source and Style


The source is going to contain the image file location. Something like this


source = require('../../../assets/user.png')

and style is going to have an Object of styles but not sure if I write style: Object will be right.


export interface AvatarProps {
source?: any; <<<<< Don't want to use any
style?: any; <<<<< Don't want to use any
shape?: string;
ImageComponent?: React.ComponentType;
size?: 'tiny' | 'small' | 'medium' | 'large' | 'giant';
}

export const Avatar: FunctionComponent<AvatarProps> = ({
shape,
style,
size = 'medium',
ImageComponent,
source = require('../../../assets/user.png'),
}) => {
return (
<View>
....
</View>
);
};


More From » reactjs

 Answers
6

source is just a string. Importing binary data is not necessary; often all we need is a URL。


For style, since you are using React, you can use React.CSSProperties to be its type.


[#1982] Wednesday, January 6, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ravenl

Total Points: 338
Total Questions: 107
Total Answers: 112

Location: Belize
Member since Mon, Jun 20, 2022
2 Years ago
ravenl questions
Thu, Feb 18, 21, 00:00, 3 Years ago
Tue, Mar 17, 20, 00:00, 4 Years ago
Tue, Dec 3, 19, 00:00, 5 Years ago
;