aksonov / aksonov/react-native-router-flux

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

Ouverte
#3,358 6 commentaires 5 réactions 0 personnes assignées Voir sur GitHub
documentation
Langage dominant
JavaScript
Étoiles
8.9k
Forks
2.1k
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

**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 ``` /*code*/}/>``` will not help.

- ```/*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)

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.