How to show flatlist result on screen by click on stack screen header button?

Viewed 46

I want to show the sorting flatlist result on home screen by clicking on stack screen header button. But the stack screen function is different from home screen. In sort, when I click on button(on stack screen) then show the result on home screen in flatlist. Below are the images for reference:

Step-1:

Step-1: here I've call onpress action for modal

Step-2:

Step-2: after click modal open for options. On click any options the result should be appear on home screen

1 Answers

Have you tried using the Context API provided by react? it works by wrapping your application in a provider that can be accessed by both your header and your screen, that way the header can modify the data stored in the context, and the screen immediately consumes the data modified (shared data between components in different hierarchies)

Take a look at the docs, Ben Awad does a great job at explaining it in this video if you're more of a visual learner, his use case is for web development, but the same concept applies for React Native.

Hope you find this helpful!

Related