React Native Router Flux Actions.currentParams props

Viewed 194

This is not a problem, more of a curious question.

I have been using Actions.currentParams props for awhile now to either get Object information on current screen or to do things like Actions.currentParams.backAndroidHandler() to access the function I passed to RNRF's Router.

I found this trick upon browsing on threads, but found no explanations for it and how it works. Couldn't find any documentation either on RNRF's github. Any information I have now are mainly based on printing the props to console and dissecting and speculating answers from that. I guess it just bugs me to operate blindly like this without concrete documentation on the things I use in my code.

If you have any information on this, links to material readings would be greatly appreciated, because it's been bugging me for DAYS now! lol

1 Answers

I found something in document.

It looks have some relevance. Hope it helps.

...
onNavigationStateChange = async (prevState, currentState, action) => {
    this.state = currentState;
    this.prevState = prevState;
    const activeState = getActiveState(this.state);
    const currentScene = activeState.routeName;
    this.currentParams = { ...activeState.params, ...action.params }; //Here!!
    this.currentScene = currentScene;
    this.prevScene = this.prevState ? getActiveState(this.prevState).routeName : null;
    if (this.currentScene !== this.prevScene) {
      // run onExit for old scene
      this.onExitHandler(this.prevScene);
      setTimeout(() => this.dispatch({
        type: ActionConst.FOCUS,
        routeName: this.currentScene,
        params: this.currentParams,
      }));
      this.onEnterHandler(currentScene);
}
...
Related