简体   繁体   中英

How to create a real-time React application?

I want to create a real-time news application. Just think of a list of countries and the news about that country next to the country name. But the news column should be automatically updated when new news is added to the API. For Example, I have this endpoint: https://newsdata.io/api/1/news?apikey=YOUR_API_KEY&country=au In this case, the country is Austria. How can my react application automatically checks the server and fetch the data if there is an update? I don't want to use setInterval to check it in specific time ranges, can socket io be used in this case?

You can use "socket.io-client" for your react app and "socket.io" for your node server. Your server can raise an event that the react app can handle with the help of "socket.io-client" after each update of the API

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM