Skip to content

Instantly share code, notes, and snippets.

View Ribeiro-Tiago's full-sized avatar

Tiago Ribeiro Ribeiro-Tiago

View GitHub Profile
const prevGetStateForAction = myStack.router.getStateForAction;
myStack.router.getStateForAction = (action , state) => {
if (state && action.type === "Navigation/NAVIGATE") {
// do stuff
}
return prevGetStateForAction(action, state);
};
export default createStackNavigator({
Home,
Settings,
Profile
}, {
transitionConfig: transitioner
})
const transitioner = (): TransitionConfig => {
return {
transitionSpec: {
duration: 400
},
screenInterpolator: (transitionProps: NavigationTransitionProps) => {
const { position, scene } = transitionProps;
const index = scene.index;
}
}
const stack = createStackNavigator({
Home,
Settings,
Profile
})
interface Props {
navigation: NavigationScreenProp<any, any>;
}
class Home extends React.Component<Props> {
render() {
return (
<View style={{ flex: 1, justifyContent: "space-around", alignItems: "center" }}>
<Text style={{ fontSize: 48, fontWeight: "bold" }}>Home Screen</Text>
<Button title="Profile" onPress={() => this.props.navigation.navigate("Profile")} />