I'd like to use constants from Data.tsx
in `OtherScreen.tsx' without exporting the constants. How can I do this? If React Context is the only way, how can I implement that in this situation?
Data.tsx
interface DataCardProps { onPress: () => void;}const Covid19DataCard = ({ onPress }: DataCardProps) => { const [earliest2, setEarliest2] = useState([]); const [countryDeaths, setcountryDeaths] = useState(Number); const [countryCases, setcountryCases] = useState(Number); useEffect(() => { axios .get("https://coronavirus-19-api.herokuapp.com/countries") .then((response) => { setEarliest2(response.data); const enteredCountryName = countryNameshort; const countryArray = response.data.filter( (item) => item.country === enteredCountryName ); const resCountryDeaths = countryArray[0].deaths; setcountryDeaths(resCountryDeaths); const resCountryCases = countryArray[0].cases; setcountryCases(resCountryCases); }) .catch((err) => { console.log(err); }); }, []);}
OtherScreen.tsx
import Data from './Data';const OtherScreen = ({ navigation,}: StackNavigationProps<Routes, "SearchScreen">) => {<Text>{Data.countryCases}</Text> //???}export default OtherScreen;