Skip to content
Advertisement

How to change the style with props

How to change the style in React Native?

I need to change the color of the text when it is true or false here is my code:

Styles Area

JavaScript

Main

JavaScript

Props

JavaScript

Here i want to change the color of the Text to green when its false or red when its true How to actually apply the color without getting an error?

Advertisement

Answer

One way to do it is to change the style object to function instead. That function will take a parameter that will be used to define the text color:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement