0
In the React-Native.js you can simply access any property as follows:
const meuComponent = (props)=>{
return(...);
}
Inside the component, you can access any property transferred to it, provided you put inside the tag
:
<MeuComponente algumaProp="qualquer coisa" />
Therefore, with props.AlgumaProp
can access what was passed by the component or screen that used.
I’d like to know how to do that in React-Native.ts, follows my code:
interface ButtonsProps extends TouchableOpacityProps{
title: string;
enabled: boolean;
}
...
const styles = StyleSheet.create({
container:{
backgroundColor: props.enabled? colors.green: colors.heading,
height:56,
borderRadius:16,
justifyContent:'center',
alignItems:'center'
}
This does not answer the question. It wants to access the prop in the stylesheet statement
– Rafael Tavares
Well observed I misunderstood the topic, but from what I saw you can use the stylesheet as a function and pass the props as parameter and use in styling https://stackoverflow.com/questions/42707327/passing-props-into-external-stylesheet-in-React-Native
export const styles = (iconColor,iconSize) => StyleSheet.create({
 icon : {
 color: iconColor,
 fontSize: iconSize
 }
}
@Rafaeltavares thanks for the remark.– Anna Rafaela