React-native-router-flux: App hangs on use of Actions.refresh()

Created on 12 Jan 2018  路  5Comments  路  Source: aksonov/react-native-router-flux

Version

Tell us which versions you are using: 4.0.0-beta.24

Expected behaviour

App should not hang after rendering view using Actions.refresh(); on NavigationBar after performing some action such as API call.

Actual behaviour

App hangs after rendering view using Actions.refresh(); on NavigationBar after performing some action such as API call / in-app logic.
Error: Maximum call stack reached
XHR finished loading: POST "http://localhost:8082/callback_result".
XHR finished loading: POST "http://localhost:8082/call_method".

All 5 comments

I encountered similar problem after migrated to v4, especially when doing Action.refresh in componentDidMount. The setTimeout temporary workaround seems to have worked for me.

setTimeout(() => {
  Actions.refresh({
    param1: 'blah1',
    param1: 'blah2',
  });
}, 0);

@simonso3 that workaround do not seam to work for me.

Are you calling it multiple times relatively quickly? I had the same problem when I discovered a bug in my code that I was calling refresh multiple times unnecessarily.

@simonso3 I encountered this when calling Actions.refresh() both on componentDidMount and componentWillReceiveProps. Former is to set a default navigation bar component, latter is to update it. If Actions.refresh() fired too quickly, RNRF will loop in Navigation/SET_PARAMS and cause app to freeze.

Use setTimeout for this.

Was this page helpful?
0 / 5 - 0 ratings