I am pulling api data manually and need to check for changes instantly trying to figure the best way but my code only pulls the data once. how do I get it to pull data constantly or indefinitely
import React, {useState, useEffect} from 'react';
const Engine = () => {
const [information, setInformation] = useState(null);
useEffect(() => {
fetch('http://127.0.0.1:63726')
.then((response) => response.json())
.then((json) => {
setInformation(json[0]);
console.log('You can see the info here', information);
})
.catch((error) => console.error(error));
}, [information]);
return <></>;
};
export default Engine;
I need react to check api none stop and update the state with any changes
question from:
https://stackoverflow.com/questions/65835143/react-native-how-call-api-or-run-a-function-indefinitely 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…