'Updating context state triggers goback() in stack navigator react native

I have home stack screen where there is search bar on top which takes to stack screen when clicked search result. In SearchResults Stack component there is more results with like button.

Like button updates context state when clicked. When I click the button while in SearchResults it triggers navigation.goBack() function and it returns to Home Stack.

If I remove the part that updates context state (setQuotes) it works fine and doesn't go back. Also when update local state it doesn't go back as well. It only happens when updating context state.

How can I prevent .goBack trigger when updating state onClick?

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source