From fc2a2cdf08c07993c69af18f66989bab56a001b5 Mon Sep 17 00:00:00 2001 From: csantosm <4a.santos@gmail.com> Date: Fri, 15 Oct 2021 12:53:00 +0200 Subject: [PATCH] react-native-webrtc: force rendering view after reconnection --- openvidu-react-native/App.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/openvidu-react-native/App.js b/openvidu-react-native/App.js index 5aa47eb6..2af10a1c 100644 --- a/openvidu-react-native/App.js +++ b/openvidu-react-native/App.js @@ -30,6 +30,7 @@ export default class App extends Component { audio: true, speaker: false, joinBtnEnabled: true, + isReconnecting: false, }; } @@ -127,15 +128,17 @@ export default class App extends Component { }); // On reconnection events - mySession.on('reconnecting', () => console.warn('Oops! Trying to reconnect to the session')); + mySession.on('reconnecting', () => { + console.warn('Oops! Trying to reconnect to the session'); + this.setState({ isReconnecting: true }); + }); + mySession.on('reconnected', () => { console.log('Hurray! You successfully reconnected to the session'); setTimeout(() => { - // Updated state and rendering the view avoiding frozen streams - const subs = this.state.subscribers; - this.setState({ subscribers: [] }); - this.setState({ subscribers: subs }); - }, 1000); + // Force re-render view updating state avoiding frozen streams + this.setState({ isReconnecting: false }); + }, 2000); }); mySession.on('sessionDisconnected', (event) => { if (event.reason === 'networkDisconnect') {