I am calling an api end point that should render some information. I am calling the API but need an event to trigger it. I am triggering that event with a setTimeout
function.
Although nothing is rendering, I am getting an error of Cannot read property state of undefined
This is the code:
const TermsAndCond = () => { const [terms] = useState(''); const callTerms = () => { Terms({ terms: terms }) .then((resp: any) => { if (resp.statusCode === 200) { setTimeout(() => { ({ callTerms: resp }); }, 1000); } console.log('Data time', resp); }) .catch((error: any) => { console.log(error); }); }; return (<><SafeAreaView><Text>Terms & Conditions</Text><Button title='hellow' onPress={callTerms} /></SafeAreaView></> );};