Skip to content

Commit 51a3513

Browse files
authored
Fix/remove node link scu methods (#18)
* Remove unecessary shouldComponentUpdate implementations * Fix small lint issue * Small fix on hardcoded value
1 parent c3cdffc commit 51a3513

File tree

7 files changed

+14
-30
lines changed

7 files changed

+14
-30
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = {
2525
"camelcase": "error",
2626
"keyword-spacing": "error",
2727
"max-len": ["error", 120, 4, { "ignoreComments": true }],
28-
"max-lines": ["error", {"max": 250, "skipComments": true}],
28+
"max-lines": ["error", {"max": 300, "skipComments": true}],
2929
"newline-after-var": ["error", "always"],
3030
"no-nested-ternary": "error",
3131
"no-useless-constructor": "error",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"docs": "npm run docs:lint && node_modules/documentation/bin/documentation.js build src/**/*.js -f html -o gen-docs && node_modules/documentation/bin/documentation.js build src/**/*.js -f md > gen-docs/DOCUMENTATION.md",
1515
"docs:lint": "node_modules/documentation/bin/documentation.js lint src/**/*.js",
1616
"docs:watch": "node_modules/documentation/bin/documentation.js build src/**/*.js -f html -o gen-docs --watch",
17-
"lint": "node_modules/eslint/bin/eslint.js --config=.eslintrc.js \"src/**/*.js\"",
17+
"lint": "node_modules/eslint/bin/eslint.js --config=.eslintrc.js \"src/**/*.js*\"",
1818
"test": "jest --verbose --coverage",
1919
"test:clean": "jest --no-cache --updateSnapshot --verbose --coverage",
2020
"test:watch": "jest --verbose --watchAll"

src/components/Graph/helper.jsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,16 @@ function _buildNodeLinks(nodeId, nodes, links, config, linkCallbacks, someNodeHi
9898

9999
if (nodes[target]) {
100100
const key = `${nodeId}${CONST.COORDS_SEPARATOR}${target}`;
101-
const props = _buildLinkProps(source, target, nodes, links, config, linkCallbacks, someNodeHighlighted, transform);
101+
const props = _buildLinkProps(
102+
source,
103+
target,
104+
nodes,
105+
links,
106+
config,
107+
linkCallbacks,
108+
someNodeHighlighted,
109+
transform
110+
);
102111

103112
linksComponents.push(<Link key={key} {...props} />);
104113
}

src/components/Link/index.jsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,6 @@ export default class Link extends React.Component {
2727
*/
2828
handleOnClickLink = () => this.props.onClickLink && this.props.onClickLink(this.props.source, this.props.target);
2929

30-
shouldComponentUpdate(nextProps) {
31-
// Properties more likely to mutate are evaluated first to take advantage of short-circuit evaluation
32-
return nextProps.x1 !== this.props.x1 || nextProps.y1 !== this.props.y1
33-
|| nextProps.x2 !== this.props.x2 || nextProps.y2 !== this.props.y2
34-
|| nextProps.opacity !== this.props.opacity
35-
|| nextProps.stroke !== this.props.stroke
36-
|| nextProps.strokeWidth !== this.props.strokeWidth
37-
|| nextProps.color !== this.props.color;
38-
}
39-
4030
render() {
4131
const lineStyle = {
4232
strokeWidth: this.props.strokeWidth,

src/components/Node/const.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export default {
33
START_ANGLE: 0,
44
END_ANGLE: 2 * Math.PI
55
},
6+
DEFAULT_NODE_SIZE: 80, // FIXME: This value should come from ../Graph/config.js
67
NODE_LABEL_DX: '.90em',
78
NODE_LABEL_DY: '.35em',
89
SYMBOLS: {

src/components/Node/helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function _convertTypeToD3Symbol(typeName) {
5353
* @return {Object} concrete instance of d3 symbol.
5454
* @memberof Node/helper
5555
*/
56-
function buildSvgSymbol(size=80, symbolTypeDesc=CONST.SYMBOLS.CIRCLE) {
56+
function buildSvgSymbol(size=CONST.DEFAULT_NODE_SIZE, symbolTypeDesc=CONST.SYMBOLS.CIRCLE) {
5757
return d3Symbol()
5858
.size(() => size)
5959
.type(() => _convertTypeToD3Symbol(symbolTypeDesc))(); // @todo: Strange behavior Symbol ret function

src/components/Node/index.jsx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,6 @@ export default class Node extends React.Component {
5858
*/
5959
handleOnMouseOutNode = () => this.props.onMouseOut && this.props.onMouseOut(this.props.id);
6060

61-
shouldComponentUpdate(nextProps) {
62-
// Properties more likely to mutate are evaluated first to take advantage of short-circuit evaluation
63-
return nextProps.cx !== this.props.cx || nextProps.cy !== this.props.cy
64-
|| nextProps.opacity !== this.props.opacity
65-
|| nextProps.fill !== this.props.fill
66-
|| nextProps.fontWeight !== this.props.fontWeight
67-
|| nextProps.fontSize !== this.props.fontSize
68-
|| nextProps.label !== this.props.label
69-
|| nextProps.cursor !== this.props.cursor
70-
|| nextProps.size !== this.props.size
71-
|| nextProps.type !== this.props.type
72-
|| nextProps.renderLabel !== this.props.renderLabel
73-
|| nextProps.stroke !== this.props.stroke
74-
|| nextProps.strokeWidth !== this.props.strokeWidth;
75-
}
76-
7761
render() {
7862
const gProps = {
7963
className: this.props.className,

0 commit comments

Comments
 (0)