I'm working with react Navigation 5.x. My requirement is to create a screen having multiple material top tabs inside one of stack navigation screens.
When the Clinics screen is opened, an API needs to be called to set some data as state and the data needs to be shared across all three tabs(example: if API returns 10 numbers, all even numbers to be listed in tab 1 and odd ones in tab 2).
How do I achieve this? Thanks in advance.
I was carried away by the navigation.setParams() and overlooked react hooks.
Achieved the required with the useContext, useState and useEffect.
Added a ClinicsProvider.js that creates context, useState to maintain state of data, useEffect to make api call and setData. Wrapped the ClinicsProvider around stack navigator which contains tab navigator. Each tab screen then import the ClinicsContext by using the useContext hook and access the API data.