React-native-router-flux: Action.refresh not working second time for current screen.

Created on 7 Feb 2018  路  4Comments  路  Source: aksonov/react-native-router-flux

Version

-Router.js

const RouterWithRedux = connect()(Router);
const RouterComponent = () => {
    return (
        <View style={{ flex: 1 }}>
            <Header />
                <RouterWithRedux>
                    <Scene key='root' hideNavBar gestureEnabled={false} panHandlers={null} duration={0}>
                        <Scene key='auth' hideNavBar initial duration={0}>
                            <Scene
                                key='Login'
                                component={Login}
                                title='Login'
                            />
                        </Scene>
                        <Scene key='Main' hideNavBar duration={0}>
                            <Scene
                                key='Wallet'
                                component={Wallet}
                                title='Wallet'
                            />
                            <Scene
                                key='Card'
                                component={Card}
                                title='Card'
                            />
                        </Scene>
                    </Scene>
                </RouterWithRedux>
            <Bottom />
        </View>
    );
};

export default RouterComponent;

-Header.js

onPress(button) {
    Keyboard.dismiss();
    Actions.refresh({ key: Actions.currentScene });
}

Hear my routing file and header file onpress method.

-On Press button i want refresh current screen on header file.
-When i refresh first time Actions.refresh working.
-Second time not Actions.refresh not working for current screen.

Most helpful comment

It makes sense..

All 4 comments

i refresh same page second time.

First time - Actions.refresh({ key: 'Wallet'}); 
Second time - Actions.refresh({ key: 'Wallet'}); 

Any solution for second time same page refresh?

I am having same issue,
I tried to console.log the prop inside the componentWillReceiveProps
First time I can see the prop value
Second time the console.log is not run. So nothing is displayed.

Okay I found the issue f and fixed my problem.
The problem is that if you pass the same parameter to Actions.refresh, then the refresh doesn't happen, so I have added one more variable and gave it a "Math.random()" value. which makes sure the view is updated everytime.

It makes sense..

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VictorK1902 picture VictorK1902  路  3Comments

vinayr picture vinayr  路  3Comments

xnog picture xnog  路  3Comments

llgoer picture llgoer  路  3Comments

basdvries picture basdvries  路  3Comments