question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Some helpful tips on using the on Methods [Router flux v4.0.6]

See original GitHub issue

Using Static on Methods with HOCs This is just a helpful tip for anyone who use the onExit/onEnter methods as a static method in their Component Class. Please refer to this link https://reactjs.org/docs/higher-order-components.html.

  • If your Scene Components are Wrapped in Custom HOCs/ Decorators, then the static onExit/onEnter methods will not work as your Custom HOCs will not copy the static methods over to your Enhanced Component.

  • Use this npm package called hoist-non-react-statics to copy your Component level static methods over to your Enhanced Component.

Implement onBack from your Scene and not while declaring the Scene

  • If you have a Scene where in you want to make some changes to your Component State when Back button is pressed, then doing this <Scene key={...} component={...} onBack={()=>/*code*/}/> will not help.

  • <Scene key={...} component={...} onBack={()=>/*code*/} back={true}/> Make sure back = true is passed to your scene, now in your Component’s lifecycle add this

componentDidMount(){
    setTimeout(()=> {
        Actions.refresh({onBack:()=>this.changeSomethingInYourComponent()})
    })
}
  • setTimeout is added because without setTimeout props of the prev screen get refreshed, may be because it waits for the animation to complete, so better to run it on a fresh queue.(Clarification required)

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:5
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
aksonovcommented, Jan 4, 2019

@shubhang93 Great tips, thanks! It would be great if you can submit documentation PR

1reaction
ValentinBlokhincommented, Nov 27, 2018

In case of animations and refresh props, it’s better to use const params = { onBack: this.onBack, onRight: this.onRight } InteractionManager.runAfterInteractions(() => { Actions.refresh(params); });

because

InteractionManager allows long-running work to be scheduled after any interactions/animations have completed

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-native-router-flux - npm
Use Actions.currentScene to get name of current scene. Helpful tips if you run into some gotchas. Using Static on Methods with ...
Read more >
What is the proper way to pass props through Actions in react ...
I just upgraded from v4.0.0-beta.31 to v4.0.6 and my data isnt being passed through the Actions method. It worked perfectly before i ...
Read more >
react-native-router-flux tab's on press is not working after ...
Its working fine in iOS Release & Debug along with Android Debug. But in Android release mode, switching between tabs is not working...
Read more >
react-native-router-flux-czr - npm package - Snyk
Use Actions.currentScene to get name of current scene. Helpful tips if you run into some gotchas. Using Static on Methods with HOCs.
Read more >
How to make this network work in this special case?
Some of iptables' actions will still cause routing decision alterations ... src 192.168.0.6 ip route add table 10 default via 192.168.0.1.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found