简体   繁体   中英

Make a reusable component in Reach which takes same inputs but with different styles

How do you make a component in react which takes different classNames?

For eg let's have a reusable component that takes an image and a text. I want to use this component on 2 different pages but I want different font sizes for the text(18px & 24px).

I create the component and pass it the text and image. But how do I change the style?

const Reusable = ({styles, text , imgUrl}) => {
    return (
        <img src={imgUrl} alt={text} style={{...styles}} />
    )
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM