-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@embark/core): Prevent unnecessary re-renderings
The services websocket was initiated in the AppContainer and causing all child components to continuously re-render every time there was a service check (which is effectively every second). In addition, the socket was never stopped when not needed (ie when the services component was unmounted). Create a ServicesContainer that initiates the websocket as part of the container, and stops the socket when the container is unmounted. Move the ContractsList to be part of the ContractsContainer with a `mode` switch. Add Deployment page title and description.
- Loading branch information
1 parent
cc495c5
commit 128ecd4
Showing
8 changed files
with
138 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import PropTypes from "prop-types"; | ||
import React, {Component} from 'react'; | ||
import {connect} from 'react-redux'; | ||
import Services from '../components/Services'; | ||
import { | ||
listenToServices as listenToServicesAction, | ||
services as servicesAction, | ||
stopServices as stopServicesAction | ||
} from "../actions"; | ||
import DataWrapper from "../components/DataWrapper"; | ||
import {getServices} from "../reducers/selectors"; | ||
|
||
class ServicesContainer extends Component { | ||
componentDidMount() { | ||
this.props.fetchServices(); | ||
this.props.listenToServices(); | ||
} | ||
|
||
componentWillUnmount() { | ||
this.props.stopServices(); | ||
} | ||
|
||
render() { | ||
return <DataWrapper shouldRender={this.props.services.length > 0 } {...this.props} render={({services}) => ( | ||
<Services services={services} /> | ||
)} />; | ||
|
||
} | ||
} | ||
|
||
ServicesContainer.propTypes = { | ||
fetchServices: PropTypes.func, | ||
listenToServices: PropTypes.func, | ||
}; | ||
|
||
function mapStateToProps(state, _props) { | ||
return { | ||
services: getServices(state) | ||
}; | ||
} | ||
|
||
export default connect( | ||
mapStateToProps, | ||
{ | ||
fetchServices: servicesAction.request, | ||
listenToServices: listenToServicesAction, | ||
stopServices: stopServicesAction | ||
} | ||
)(ServicesContainer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters