Как исправить, что WebApp сохраняет состояние рендеринга?

После недельного эксперимента

я нашел решение

, которое я расширил его внутри графика.

после того, как я вставил данные в кэш.

APRegisterExt GetAPExtension = APGraph.Document.Current.GetExtension<APRegisterExt>();

Этот трюк работает для меня. Спасибо за ваше предложение! :)

1
задан Thiii 20 January 2019 в 00:08
поделиться

1 ответ

Вы можете использовать setInterval, чтобы ограничить частоту выполнения кода, например

setInterval(function(){
    if (props.city) {
        useEffect(() => {
            fetch(`https://api.openweathermap.org/data/2.5/weather?q=${props.city}&units=metric&APPID=af081727ae6d5c4cbe2cd266b726e632`).then(results => {return results.json();}
            ).then(data => setWind(data.wind.speed))
        })
        useEffect(() => {
            fetch(`https://api.worldweatheronline.com/premium/v1/weather.ashx?key=a5bf94fc16c84928acb114156182311&q=${props.city}&num_of_days=1&tp=24&format=json`).then(results => {return results.json();}
            ).then(data => setPrecipitation(data.data.weather[0].hourly[0].chanceofrain))
        })
        useEffect(() => {
            fetch(`https://api.openweathermap.org/data/2.5/weather?q=${props.city}&units=metric&APPID=af081727ae6d5c4cbe2cd266b726e632`).then(results => {return results.json();}
            ).then(data => setPressure(data.main.pressure))
        })        
        useEffect(() => {
            fetch(`https://api.openweathermap.org/data/2.5/weather?q=${props.city}&units=metric&APPID=af081727ae6d5c4cbe2cd266b726e632`).then(results => {return results.json();}
            ).then(data => setHumidity(data.main.humidity))
        })}}, 10000);

, а затем просто настроить время для проверки того, как часто вы хотите его проверять

0
ответ дан Andre 20 January 2019 в 00:08
поделиться
Другие вопросы по тегам:

Похожие вопросы: