Skip to content

Commit b351d41

Browse files
authored
github-fixes-#31-error-maximum-call-stack-exceeded (#39)
* github-fixes-#31-error-maximum-call-stack-exceeded * remove equals function since it does not work with cyclic objects and it is not used anymore
1 parent 12c3163 commit b351d41

File tree

5 files changed

+15
-726
lines changed

5 files changed

+15
-726
lines changed

src/Util/Util.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ export debounce from './debounce';
22
export firstDefined from './firstDefined';
33
export closestAbove from './closestAbove';
44
export {requestAnimationFrame, cancelAnimationFrame } from './requestAnimationFrame';
5-
export equals from './equals';
65
export isElement from './isElement';

src/Util/equals.js

Lines changed: 0 additions & 207 deletions
This file was deleted.

src/components/Image/Image.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, {Component} from 'react';
22
import cloudinary, {Util} from 'cloudinary-core';
33
import CloudinaryComponent from '../CloudinaryComponent';
4-
import {debounce, firstDefined, closestAbove, requestAnimationFrame, equals, isElement} from '../../Util';
4+
import {debounce, firstDefined, closestAbove, requestAnimationFrame, isElement} from '../../Util';
55

66
/**
77
* A component representing a Cloudinary served image
@@ -32,10 +32,6 @@ class Image extends CloudinaryComponent {
3232
return (this.element && this.element.ownerDocument) ? (this.element.ownerDocument.defaultView || windowRef) : windowRef;
3333
}
3434

35-
shouldComponentUpdate( nextProps, nextState){
36-
return !( equals(this.props, nextProps) && equals(this.state, nextState));
37-
}
38-
3935
componentWillReceiveProps(nextProps, nextContext) {
4036
let state = this.prepareState(nextProps, nextContext);
4137
this.setState(state);

test/ImageTest.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import { expect } from 'chai';
33
import { shallow, mount, render } from 'enzyme';
44
import Image from '../src/components/Image';
5+
import Transformation from '../src/components/Transformation';
56

67
describe('Image', () => {
78
beforeEach(() => {
@@ -51,4 +52,17 @@ describe('Image', () => {
5152
expect(tag.props()).not.to.have.property('default_image');
5253

5354
});
55+
it("should not fail to update cyclic property on an image element with transformation", function() {
56+
// makes sure Issue #31 - Error: Maximum call call stack size exceeded does not reoccur
57+
let obj1 = {}, obj2 = {};
58+
obj1.me = obj1;
59+
obj2.me = obj2;
60+
61+
let tag = shallow(<Image publicId="sample" cloudName="demo"><Transformation effect='art:hokusai'/></Image>);
62+
tag.setProps({cyclicProp: obj1});
63+
tag.setProps({cyclicProp: obj2});
64+
65+
tag.setState({cyclicProp: obj1});
66+
tag.setState({cyclicProp: obj2});
67+
});
5468
});

0 commit comments

Comments
 (0)