0
import AsyncStorage from '@react-native-async-storage/async-storage';

let data;

const fetchData = () => {
  AsyncStorage.getItem('apiData')
    .then(storedData => {
      data = JSON.parse(storedData);
    })
    .catch(error => {
    });
};

fetchData();
console.log(data)

export { data };

I have tried assigning value with the string (data="Data is present"). It gives that changeable value. But I tried with (data = JSON.parse(storedData);) not given. Please help me with a solution.

0 Answers0