aksonov / aksonov/react-native-router-flux

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

Abierto
#3,699 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
8.9k
Forks
2.1k
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

### 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.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.