Thursday, December 1, 2022
HomeiOS Developmentandroid - Altering coloration with occasion listener works on net, however not...

android – Altering coloration with occasion listener works on net, however not on cellphone


I need to change the colour of a button and lauch a perform when urgent it. I works on net with this code :

   changeColor= occasion =>{
            occasion.currentTarget.model.backgroundColor="salmon";
      }
  
     
        
  render(){
    return(
      
    
      <View model={types.container}> 
{ this.state.wordsToUse.map(phrase=>(
       <Textual content model={types.textual content}>{phrase}</Textual content>
     ))}
     <Button title ="C'est deviné !" onPress={()=>{
        this.motDevine()
      }}/>
      
           <Textual content model={types.textual content}> Temps restant : {this.state.timeLeft}</Textual content>
{ this.state.lettersToUse.map(letter=>(
  
  <TouchableHighlight
  model={types.buttonLetterInactive}
  activeOpacity={0.6}
  underlayColor="#DDDDDD"

  onPressIn={()=>this.useLetter(letter)}
  onLongPress={()=>this.passWords(letter)}     
  onPress={this.changeColor}

>

Nevertheless, it doesn’t on androids or IOS !The probleme is with the changeColor perform. If I delete ‘ onPress={this.changeColor}”, there is no such thing as a bug however the coloration shouldn’t be modified.

WHen I press the button, that is the error I get : undefined shouldn’t be an object (evaluating ‘occasion.currentTarget.model.backgroundColor=”salmon”‘)

I had no thought it was even attainable. Are you able to please clarify why and what ought to I do to unravel the issue ?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments