react-native-router-flux: Actions.refresh not working

Version

Tell us which versions you are using:

  • react-native-router-flux v4.0.0-beta.12
  • react-native v0.46.4

Expected behaviour

Actions.refresh() refresh the current scene. If my approach was wrong, or Actions.refresh has some requirement, please provide me with the information

Actual behaviour

const ConnectRouter = connect()(Router);

const Routes = () => (
  <ConnectRouter>
    <Scene key="root">
      <Scene key="launchScreen" component={LoadingFull} hideNavBar />
      <Scene key="login" component={LoginForm} hideNavBar type={ActionConst.RESET} />
      <Scene key="lostPassword" component={LostPasswordForm} hideNavBar />
      <Scene key="dashboard" component={Dashboard} hideNavBar type={ActionConst.RESET} />
      <Scene key="search" component={SearchResult} hideNavBar />
    </Scene>
  </ConnectRouter>
);

When i was at search scene (plain component with state), i was trying to refresh the scene by using Actions.refresh. But somehow it didn’t work at all.

Steps to reproduce

  1. Using provided scene list go to search Component (it was just plain component with state)
  2. trigger actions.refresh by pressing button/ triggering some event

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 8
  • Comments: 24 (5 by maintainers)

Most upvoted comments

@jaysassyinfotech Actions.refresh({ key: Actions.currentScene }); not working second time It works if you do like this 😃 Actions.refresh({key: Math.random()})

Jesus, I came here looking for an answer for the original issue. Please, try not to piggyback on non related issues !

public componentWillMount (): void { this.props.navigation.setParams({ onRight: () => {this.myOnRight();}, rightTitle:‘newTitle’, }); } It working for me.

It works for me. rnrf-4-beta22

leftButton for left icon right for right icon

+1 i want to use renderBackButton from scene. My example code,

public componentWillMount (): void {
               Actions.refresh({
			renderBackButton: this.renderBackButton.bind(this),
			onRight: this.onRightButtonPress.bind(this)
		});
}

It’s not working. I think it’s same issue.

@kesha-antonov It’s not working. I create new issue for this.

Try leftButton instead of renderBackButton and pass Component to it.

@cosinus84 You sir are a lifesaver.

@cosinus84 It is really work. wow But is there any explaination why Math.random() does all the tricks?

Actions.refresh({ key: Actions.currentScene }); not working second time https://github.com/aksonov/react-native-router-flux/issues/2862 @aksonov

Hi

I have the same problem … When i try to refresh with Actions.refresh() nothing happen

import React, { Component } from 'react';
import {
    View,
    Text,
    Button,
} from 'react-native';

import { Actions } from 'react-native-router-flux';

export default class Types extends Component {

    constructor(props) {
        super(props);
        console.log("Constructor Types")
    }

    componentWillMount() {
        console.log('Will mount Types')
    }

    componentWillUpdate() {
        console.log("Will Update Types")
    }

    componentWillUnmount() {
        console.log("will Unmont Types")
    }
    render() {
        console.log("render Types")
        return (
            <Button title='refresh' onPress={() => Actions.refresh()}/>
        )
    }
}

Hopefully random is not needed for latest version now