Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6581

How to set external gradient colors and styles for React Native's LinearGradient?

$
0
0

"react-native-linear-gradient" how to pass colors as props and styles also

` interface Props {        // gradientColors:string[]    gradientColors:Array<string>}const BaseButton: React.FC<Props> = ({ gradientStyle ,gradientColors}) => { const styles = buttonStyle({ btnHeight,btnWidth, btnColor, btnFont, btnTextColor, btnBorderRadius,    })    const gradientColorsTest = ['#4c669f', '#3b5998', '#192f6a']    return (<LinearGradient            // colors={['#4c669f', '#3b5998', '#192f6a']}            colors={gradientColors}            // style={styles.gradient}            style={gradientStyle}            start={{ x: 0, y: 0 }}            end={{ x: 1, y: 1 }}><TouchableOpacity onPress={()=>{}}><View style={styles.buttonViewStyle}><Text>ButtonTest</Text></View></TouchableOpacity></LinearGradient>    )}export default BaseButton`

How to send colors and style externally for linear gradient.

i was tried to pass as colors={gradientColors} but it shows error of **** Cannot read property 'map' of undefined**** how to solve this error


Viewing all articles
Browse latest Browse all 6581

Latest Images

Trending Articles



Latest Images