I use React Native component LinearGradient for a web project.
<LinearGradient colors={['rgba(0,0,0,0.7)', 'rgba(0,0,0,0)']}>
<View />
</LinearGradient>
This produces the error
Using LinearGradient for web gives error export 'requireNativeComponent' (imported as 'requireNativeComponent') was not found in 'react-native-web/dist/index'
What could be the issue and how to fix it?
2
Answers
It seems that the issue is React Native component
<LinearGradient />
does not work for the web. One of the solutions is to use<WebLinearGradient>
instead:The more dynamic and universal solution could be like this:
Linear Gradient is one of the property of React Native and react native is only a mobile application development platform . If incase you want to use gradient colors for website means you have to set background color to parent component like this ,