Skip to content
Snippets Groups Projects
Commit d80078a2 authored by Paul Kaplan's avatar Paul Kaplan
Browse files

Do not call handleConnected in componentDidMount

Two reasons: 
1. Avoid triggering "connected" event, because the device was already connected
2. It is not good to call `setState` in componentDidMount, which is effectively what it was doing.
parent 11b2fee8
No related branches found
No related tags found
No related merge requests found
......@@ -17,18 +17,13 @@ class ConnectionModal extends React.Component {
'handleHelp'
]);
this.state = {
phase: PHASES.scanning
phase: props.vm.getPeripheralIsConnected(props.extensionId) ?
PHASES.connected : PHASES.scanning
};
}
componentDidMount () {
this.props.vm.on('PERIPHERAL_CONNECTED', this.handleConnected);
this.props.vm.on('PERIPHERAL_ERROR', this.handleError);
// Check if we're already connected
if (this.props.vm.getPeripheralIsConnected(this.props.extensionId)) {
this.handleConnected();
}
}
componentWillUnmount () {
this.props.vm.removeListener('PERIPHERAL_CONNECTED', this.handleConnected);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment