aksonov / react-native-router-flux

The first declarative React Native router
MIT License
8.99k stars 2.11k forks source link

on reset complete? #2090

Closed compojoom closed 7 years ago

compojoom commented 7 years ago

Is there a way to know when a reset action has completed? I'm running in the following issue: Following scenes A -> B -> C -> D

A - list items B -> expand on a list item + additional data C -> display just the list item from the previous screen D -> edit this list item.

On the edit screen I have a delete button. If I delete the item - my redux store updates and screen B, C and D will trigger an error as the object they previously loaded is no longer there. That's why I'm trying to first reset the whole stack back to A and trigger the delete when on A. This is my code:

 Actions.reset('companies');
this.props.editCompany(null);
this.props.openCompany(null);
 companyQuery.removeCompanyRecursive(this.state.company_id);

The animation is slow to start and my app crashes because I set editcompany and opencompany to null, but the previous scenes are still mounted. If I place this in a setTimeout:

this.props.editCompany(null);
this.props.openCompany(null);
 companyQuery.removeCompanyRecursive(this.state.company_id);

then it seems to work properly, but this makes the app look unresponsive. Is there a way to know when reset has completed?

aksonov commented 7 years ago

It is kind of duplicate #2089 - you should use Redux/MobX to manage app state.