Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action.refresh not working second time for current screen. #2862

Closed
jaysassyinfotech opened this issue Feb 7, 2018 · 4 comments
Closed

Action.refresh not working second time for current screen. #2862

jaysassyinfotech opened this issue Feb 7, 2018 · 4 comments

Comments

@jaysassyinfotech
Copy link

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.

@jaysassyinfotech
Copy link
Author

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?

@zurez
Copy link

zurez commented Feb 9, 2018

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.

@zurez
Copy link

zurez commented Feb 9, 2018

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.

@Blapi
Copy link
Collaborator

Blapi commented Feb 10, 2018

It makes sense..

@Blapi Blapi closed this as completed Feb 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants