'How do I diplay data received from websocket without using state

the data from the websocket is real time. I've done it using state but problem there is by using state component re-renders a lot. Note:I am trying to make crypto ticker app, something like binance or wazirx that shows real time data of any crypto coin.



Solution 1:[1]

if you are using socket.io you can use this hook it manage connection to not create new socket each time component re-render (for exemple you can use it in your main component then pass it in props) https://www.npmjs.com/package/socket.io-react-hook

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Giverseal