auto refresh working

This commit is contained in:
erik-sn committed 2020-09-24 23:33:28 -04:00
1 parent ba0f122938
commit 997f550aab
4 files changed
+14 -7

No files matched your search

+13 -2
View File
@@ -1,12 +1,23 @@
import React from "react";
import React, { useEffect } from "react";
import Nui from "../../../os/nui-events/utils/Nui";
import { List } from "../../../ui/components/List";
import { useTweets } from "../hooks/useTweets";
import Tweet from "./Tweet";
const TWEETS_REFRESH_RATE = 5000;
export function TweetList() {
const { tweets } = useTweets();
console.log(tweets);
useEffect(() => {
Nui.send("phone:fetchTweets", {});
const timeout = window.setTimeout(() => {
Nui.send("phone:fetchTweets", {});
}, TWEETS_REFRESH_RATE);
return () => window.clearTimeout(timeout);
}, []);
return (
<List>
{tweets