aksonov / aksonov/react-native-router-flux

props passed to Router are undefined in Scene component after Actions.reset()

Aberta
#3,699 0 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
JavaScript
Estrelas
8.9k
Forks
2.1k
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

### Version
Tell us which versions you are using:

- react-native-router-flux v4.2.0
- react v16.13.1
- react-native v0.63.2

### Expected behaviour
Router props remain accessible after Actions.reset()

### Actual behaviour
props passed to Router are undefined in Scene component after Actions.reset()

### Reproducible Demo

App.js
```
class App extends Component{

constructor(props) {
super(props)
this.state ={
authenticated: false,
autoLoginCompleted: false
}
this.autologin = this.autologin.bind(this)
this.autologin()
}

render(){
if(this.state.autoLoginCompleted){
return (
<>







{this.alert = ref}}/>

)
}else return null
}

async autologin(){
// API call for autologin, sets authenticated and autoLoginCompleted based on result
}

}

export default App
```

In the Login Scene, I use `this.props.app.alert.show(error.message, 'error')` to show an error message with my custom Alert component. This is all working fine, until I logout, calling Actions.reset("login"). Then, I get this error when I try to show the alert again:

```
Possible Unhandled Promise Rejection (id: 0):

TypeError: undefined is not an object (evaluating '_this3.props.app.alert')
```

How can I maintain access to the app prop after calling Actions.reset()?

Thanks for your time.

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.