mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-21 14:27:13 +00:00
Addressed react/no-access-state-in-setstate
This commit is contained in:
committed by
Daniel Holbach
parent
f27d1337c8
commit
7c417bd5d6
@@ -157,9 +157,9 @@ class DebugToolbar extends React.Component {
|
||||
}
|
||||
|
||||
toggleColors() {
|
||||
this.setState({
|
||||
showColors: !this.state.showColors
|
||||
});
|
||||
this.setState(prevState => ({
|
||||
showColors: !prevState.showColors
|
||||
}));
|
||||
}
|
||||
|
||||
asyncDispatch(v) {
|
||||
|
||||
@@ -46,9 +46,9 @@ export default class NodeDetailsGenericTable extends React.Component {
|
||||
}
|
||||
|
||||
handleLimitClick() {
|
||||
this.setState({
|
||||
limit: this.state.limit ? 0 : NODE_DETAILS_DATA_ROWS_DEFAULT_LIMIT
|
||||
});
|
||||
this.setState(prevState => ({
|
||||
limit: prevState.limit ? 0 : NODE_DETAILS_DATA_ROWS_DEFAULT_LIMIT
|
||||
}));
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -13,8 +13,9 @@ export default class NodeDetailsHealth extends React.Component {
|
||||
}
|
||||
|
||||
handleClickMore() {
|
||||
const expanded = !this.state.expanded;
|
||||
this.setState({expanded});
|
||||
this.setState(prevState => ({
|
||||
expanded: !prevState.expanded
|
||||
}));
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -43,7 +44,7 @@ export default class NodeDetailsHealth extends React.Component {
|
||||
{...item}
|
||||
key={item.id}
|
||||
topologyId={topologyId}
|
||||
/>
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<div className="node-details-health-wrapper">
|
||||
@@ -52,7 +53,7 @@ export default class NodeDetailsHealth extends React.Component {
|
||||
{...item}
|
||||
key={item.id}
|
||||
topologyId={topologyId}
|
||||
/>
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<ShowMore
|
||||
|
||||
@@ -17,8 +17,9 @@ class NodeDetailsInfo extends React.Component {
|
||||
}
|
||||
|
||||
handleClickMore() {
|
||||
const expanded = !this.state.expanded;
|
||||
this.setState({expanded});
|
||||
this.setState(prevState => ({
|
||||
expanded: !prevState.expanded
|
||||
}));
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -28,8 +28,9 @@ export default class NodeDetailsPropertyList extends React.Component {
|
||||
}
|
||||
|
||||
handleLimitClick() {
|
||||
const limit = this.state.limit ? 0 : NODE_DETAILS_DATA_ROWS_DEFAULT_LIMIT;
|
||||
this.setState({limit});
|
||||
this.setState(prevState => ({
|
||||
limit: prevState.limit ? 0 : NODE_DETAILS_DATA_ROWS_DEFAULT_LIMIT
|
||||
}));
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -15,8 +15,9 @@ export default class NodeDetailsRelatives extends React.Component {
|
||||
|
||||
handleLimitClick(ev) {
|
||||
ev.preventDefault();
|
||||
const limit = this.state.limit ? 0 : NODE_DETAILS_DATA_ROWS_DEFAULT_LIMIT;
|
||||
this.setState({limit});
|
||||
this.setState(prevState => ({
|
||||
limit: prevState.limit ? 0 : NODE_DETAILS_DATA_ROWS_DEFAULT_LIMIT
|
||||
}));
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -41,11 +42,11 @@ export default class NodeDetailsRelatives extends React.Component {
|
||||
))}
|
||||
{showLimitAction
|
||||
&& (
|
||||
<span
|
||||
className="node-details-relatives-more"
|
||||
onClick={this.handleLimitClick}>
|
||||
{limitActionText}
|
||||
</span>
|
||||
<span
|
||||
className="node-details-relatives-more"
|
||||
onClick={this.handleLimitClick}>
|
||||
{limitActionText}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
|
||||
function getDefaultSortedBy(columns, nodes) {
|
||||
// default sorter specified by columns
|
||||
const defaultSortColumn = find(columns, {defaultSort: true});
|
||||
const defaultSortColumn = find(columns, { defaultSort: true });
|
||||
if (defaultSortColumn) {
|
||||
return defaultSortColumn.id;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ function getSortedNodes(nodes, sortedByHeader, sortedDesc) {
|
||||
// have a minimal height. That prevents auto-scroll under a focus if the
|
||||
// number of table rows shrinks.
|
||||
function minHeightConstraint(height = 0) {
|
||||
return <tr className="min-height-constraint" style={{height}} />;
|
||||
return <tr className="min-height-constraint" style={{ height }} />;
|
||||
}
|
||||
|
||||
|
||||
@@ -160,8 +160,9 @@ class NodeDetailsTable extends React.Component {
|
||||
}
|
||||
|
||||
handleLimitClick() {
|
||||
const limit = this.state.limit ? 0 : this.props.limit;
|
||||
this.setState({ limit });
|
||||
this.setState(prevState => ({
|
||||
limit: prevState.limit ? 0 : this.props.limit
|
||||
}));
|
||||
}
|
||||
|
||||
focusRow(rowIndex, node) {
|
||||
@@ -204,7 +205,7 @@ class NodeDetailsTable extends React.Component {
|
||||
|
||||
getColumnHeaders() {
|
||||
const columns = this.props.columns || [];
|
||||
return [{id: 'label', label: this.props.label}].concat(columns);
|
||||
return [{ id: 'label', label: this.props.label }].concat(columns);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
@@ -264,12 +265,12 @@ class NodeDetailsTable extends React.Component {
|
||||
<table className="node-details-table">
|
||||
<thead ref={this.saveTableHeadRef}>
|
||||
{this.props.nodes && this.props.nodes.length > 0 && (
|
||||
<NodeDetailsTableHeaders
|
||||
headers={headers}
|
||||
sortedBy={sortedBy}
|
||||
sortedDesc={sortedDesc}
|
||||
onClick={this.updateSorted}
|
||||
/>
|
||||
<NodeDetailsTableHeaders
|
||||
headers={headers}
|
||||
sortedBy={sortedBy}
|
||||
sortedDesc={sortedDesc}
|
||||
onClick={this.updateSorted}
|
||||
/>
|
||||
)}
|
||||
</thead>
|
||||
<tbody
|
||||
@@ -312,7 +313,7 @@ NodeDetailsTable.defaultProps = {
|
||||
limit: NODE_DETAILS_DATA_ROWS_DEFAULT_LIMIT,
|
||||
// key to identify a node in a row (used for topology links)
|
||||
nodeIdKey: 'id',
|
||||
onSortChange: () => {},
|
||||
onSortChange: () => { },
|
||||
sortedBy: null,
|
||||
sortedDesc: null,
|
||||
};
|
||||
|
||||
@@ -12,8 +12,9 @@ class Warning extends React.Component {
|
||||
}
|
||||
|
||||
handleClick() {
|
||||
const expanded = !this.state.expanded;
|
||||
this.setState({ expanded });
|
||||
this.setState(prevState => ({
|
||||
expanded: !prevState.expanded
|
||||
}));
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
Reference in New Issue
Block a user