Skip to content

Commit e04bfc2

Browse files
committed
Simplifies Node component updates, fixes horizontal/vertical switch bug
1 parent e9de712 commit e04bfc2

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/Node/index.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,9 @@ export default class Node extends React.Component {
2929
this.applyTransform(transform);
3030
}
3131

32-
componentWillReceiveProps(nextProps) {
33-
if (nextProps.nodeData.x !== this.props.nodeData.x ||
34-
nextProps.nodeData.y !== this.props.nodeData.y) {
35-
const transform = this.setTransformOrientation(nextProps.nodeData.x, nextProps.nodeData.y);
36-
this.applyTransform(transform);
37-
}
32+
componentWillUpdate(nextProps) {
33+
const transform = this.setTransformOrientation(nextProps.nodeData.x, nextProps.nodeData.y);
34+
this.applyTransform(transform);
3835
}
3936

4037
setTransformOrientation(x, y) {

src/Node/tests/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ describe('<Node />', () => {
170170
});
171171

172172

173-
it('updates its transform attribute if either the `x` or `y` prop changes', () => {
173+
it('applies updated transform if either the `x` or `y` prop changes', () => {
174174
// jest.spyOn(Node.prototype, 'applyTransform');
175175
const updatedProps = {
176176
...mockProps,

0 commit comments

Comments
 (0)