Skip to content

componentDidMount not trigger on Actions.pop #264

@jeremybarbet

Description

@jeremybarbet

Hi !

I would like to understand how works the Actions.pop function a little.

I have a simple app with two views. On the first one, I just display data than user have to edit by himself. And on the second screen, the edit view to add data.

By default user didn't have data display and is invited to edit data. I use a onPress={ Actions.add } to redirect him to the edit screen. After user save is data, there is a back button to call the onPress={ Actions.pop } to the list view.

This is where I struggled a little bit.

  • When I press the back button, and go back to the list view, the componentDidMount is not called again.
  • However, I have a lifecycle with componentWillReceiveProps, but the function render two times my list view. When I press the back button, componentWillReceiveProps is triggered with the old list view, and 300ms after a new componentWillReceiveProps is triggered with the new data. It seems buggy to the user to saw the last data during a second before seeing his new edited data.
  • If I replaced the onPress function with a onPress={ Actions.list } instead of Actions.pop, the componentDidMount event is mounted, but I loose my nav stacks, and the gestures are broken.

How can I fix this issue and what's the best way to do it ?

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions