0

I have this problem, my code works well but if I put an Accessory Right or Left I get the error Nothing was returned from the render. On other screen it works perfectly but on this screen it's impossible. There are some things that i really don't understand with UIKItten. Thank you for your help.

  userChange = () =>  {
    this.state.navigation.navigate('Login', {noAutoConnect : true});
  }

  Disconnect = () => {
    <TopNavigationAction icon={Quit} onPress={this.userChange}/>
  }
  
  render() {    
    return (
        <>
          <TopNavigation style={{ borderWidth: 1 }} title='Acceuil' alignment='center' accessoryLeft = {this.Disconnect}  />
            <View style = {style.lay}>
              <Button size = "giant" onPress = {this.navigateArticles} status = "danger"><Text>Accéder à mes Pdf</Text></Button>
            </View>
       </>
    );
  }
Leri Gogsadze
  • 2,958
  • 2
  • 15
  • 24
Dirk
  • 55
  • 6

1 Answers1

1

Add return in Disconnect function.

Disconnect = () => {
    return <TopNavigationAction icon={Quit} onPress={this.userChange}/>
}
Leri Gogsadze
  • 2,958
  • 2
  • 15
  • 24
  • It works, thank you. But i don't understand why i need a return on this screen and not for the other for a same function – Dirk Dec 18 '20 at 09:33
  • @Dirk Because in this case `accessoryLeft` expects some UI element that's why you need to return something from `Disconnect` function. Passing the only reference is not enough. – Leri Gogsadze Dec 18 '20 at 09:42
  • If you want to update the state or do any other stuff then there is no need to return something. – Leri Gogsadze Dec 18 '20 at 09:43
  • Ok so i guess that `navigation.goBack()` and `navigation.navigate()` are not considered like similar. it's why it works well on my others screens. Thank you a lot ! – Dirk Dec 18 '20 at 09:51