V
V
Vinkersa2021-06-18 20:40:33
React
Vinkersa, 2021-06-18 20:40:33

How to properly render URL in React JS?

Hello.
I'm doing a stream from the server on the front (React), there are problems with rendering the picture.
I receive data from the server in the form of a uint8array, process it, and eventually create a link to the finished image using URL.createObjectURL. Further, the whole thing is pushed into a state.

Further, in theory, I wanted to use this link in img.src, and calmly receive a stream of pictures, be updated, etc.

The problem arose in that it works very unpredictably. The picture appears for a fraction of a second and disappears, tobish, we have a link to the state, it is displayed and immediately disappears.
I tried to set parameters through id, I tried to use canvas for these purposes, the result is the same, the whole thing behaves very unpredictably.

I heard that the url has its own lifetime, but I don’t understand if this is the problem or not
And if this is what can be done about it

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question