1

I am new in WebRTC and I try to use it in my app. Like the tittle I am wondering should I save data like peer connection, media stream,... in useState or in Redux.

1 Answers1

0

Media stream should be saved in redux because you will need to get access to it in multiple parts of your application. For example, when you create a new connection or when you click on "end chat" button.

But I do not think that you need to store the connections in redux. you could just create a new local object in WebRTC handlers function. you can keep this on top level

let peerConnections={}

then in each handler, you can use this object. So when you export these handlers into component, because of closure, your function will always have access to this object to mutate it.

Yilmaz
  • 35,338
  • 10
  • 157
  • 202