Skip to content

Commit f4f5783

Browse files
wincentleebyron
authored andcommitted
Upgrade dependencies to fix build breakages (#238)
* Upgrade dependencies to fix build breakages We've had some lint-related build failures: https://travis-ci.org/graphql/graphiql/builds/181453346 lately. Unfortunately, these masked test failures introduced by 35d8d38. When we fixed the lint (1eeb36c), the test failures showed up: https://travis-ci.org/graphql/graphiql/builds/182431531 This commit fixes that by upgrading our deps: - Replace "react-addons-test-utils", which access a path that doesn't exist in current "react-dom", with "react-test-renderer". This required some API updates in the tests, but also some changes to use ref-based DOM node access rather than `ReactDOM.findDOMNode`, which doesn't work in "react-test-renderer". See: - facebook/react#7371 - facebook/react#8324 > Yea sorry, refs can work but `findDOMNode()` can't (we tried). * Update package.json
1 parent 1eeb36c commit f4f5783

File tree

6 files changed

+56
-25
lines changed

6 files changed

+56
-25
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@
7474
"jsdom": "9.8.3",
7575
"mocha": "3.2.0",
7676
"react": "15.4.1",
77-
"react-addons-test-utils": "15.4.0",
78-
"react-dom": "15.3.2",
77+
"react-dom": "15.4.1",
78+
"react-test-renderer": "15.4.1",
7979
"uglify-js": "2.7.5",
8080
"uglifyify": "3.0.4",
8181
"watchify": "3.7.0"

src/components/QueryEditor.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
import React, { PropTypes } from 'react';
10-
import ReactDOM from 'react-dom';
1110
import { GraphQLSchema } from 'graphql';
1211

1312
import onHasCompletion from '../utility/onHasCompletion';
@@ -59,7 +58,7 @@ export class QueryEditor extends React.Component {
5958
require('codemirror-graphql/lint');
6059
require('codemirror-graphql/mode');
6160

62-
this.editor = CodeMirror(ReactDOM.findDOMNode(this), {
61+
this.editor = CodeMirror(this._node, {
6362
value: this.props.value || '',
6463
lineNumbers: true,
6564
tabSize: 2,
@@ -139,7 +138,12 @@ export class QueryEditor extends React.Component {
139138
}
140139

141140
render() {
142-
return <div className="query-editor" />;
141+
return (
142+
<div
143+
className="query-editor"
144+
ref={node => { this._node = node; }}
145+
/>
146+
);
143147
}
144148

145149
/**
@@ -150,6 +154,13 @@ export class QueryEditor extends React.Component {
150154
return this.editor;
151155
}
152156

157+
/**
158+
* Public API for retrieving the DOM client height for this component.
159+
*/
160+
getClientHeight() {
161+
return this._node && this._node.clientHeight;
162+
}
163+
153164
_onKeyUp = (cm, event) => {
154165
const code = event.keyCode;
155166
if (

src/components/ResultViewer.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
*/
88

99
import React, { PropTypes } from 'react';
10-
import ReactDOM from 'react-dom';
11-
1210

1311
/**
1412
* ResultViewer
@@ -36,7 +34,7 @@ export class ResultViewer extends React.Component {
3634
require('codemirror/keymap/sublime');
3735
require('codemirror-graphql/results/mode');
3836

39-
this.viewer = CodeMirror(ReactDOM.findDOMNode(this), {
37+
this.viewer = CodeMirror(this._node, {
4038
lineWrapping: true,
4139
value: this.props.value || '',
4240
readOnly: true,
@@ -70,7 +68,12 @@ export class ResultViewer extends React.Component {
7068
}
7169

7270
render() {
73-
return <div className="result-window" />;
71+
return (
72+
<div
73+
className="result-window"
74+
ref={node => { this._node = node; }}
75+
/>
76+
);
7477
}
7578

7679
/**
@@ -80,4 +83,11 @@ export class ResultViewer extends React.Component {
8083
getCodeMirror() {
8184
return this.viewer;
8285
}
86+
87+
/**
88+
* Public API for retrieving the DOM client height for this component.
89+
*/
90+
getClientHeight() {
91+
return this._node && this._node.clientHeight;
92+
}
8393
}

src/components/VariableEditor.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
import React, { PropTypes } from 'react';
10-
import ReactDOM from 'react-dom';
1110

1211
import onHasCompletion from '../utility/onHasCompletion';
1312

@@ -57,7 +56,7 @@ export class VariableEditor extends React.Component {
5756
require('codemirror-graphql/variables/lint');
5857
require('codemirror-graphql/variables/mode');
5958

60-
this.editor = CodeMirror(ReactDOM.findDOMNode(this), {
59+
this.editor = CodeMirror(this._node, {
6160
value: this.props.value || '',
6261
lineNumbers: true,
6362
tabSize: 2,
@@ -136,7 +135,12 @@ export class VariableEditor extends React.Component {
136135
}
137136

138137
render() {
139-
return <div className="codemirrorWrap" />;
138+
return (
139+
<div
140+
className="codemirrorWrap"
141+
ref={node => { this._node = node; }}
142+
/>
143+
);
140144
}
141145

142146
/**
@@ -147,6 +151,13 @@ export class VariableEditor extends React.Component {
147151
return this.editor;
148152
}
149153

154+
/**
155+
* Public API for retrieving the DOM client height for this component.
156+
*/
157+
getClientHeight() {
158+
return this._node && this._node.clientHeight;
159+
}
160+
150161
_onKeyUp = (cm, event) => {
151162
const code = event.keyCode;
152163
if (

src/components/__tests__/GraphiQL-test.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import { expect } from 'chai';
1010
import { describe, it } from 'mocha';
1111
import React from 'react';
12-
import { renderIntoDocument } from 'react-addons-test-utils';
12+
import ReactTestRenderer from 'react-test-renderer';
1313

1414
import { GraphiQL } from '../GraphiQL';
1515

@@ -47,38 +47,40 @@ describe('GraphiQL', () => {
4747
const noOpFetcher = () => {};
4848

4949
it('should throw error without fetcher', () => {
50-
expect(() => renderIntoDocument(
50+
expect(() => ReactTestRenderer.create(
5151
<GraphiQL />
5252
)).to.throw(
5353
'GraphiQL requires a fetcher function'
5454
);
5555
});
5656

5757
it('should construct correctly with fetcher', () => {
58-
expect(() => renderIntoDocument(
58+
expect(() => ReactTestRenderer.create(
5959
<GraphiQL fetcher={noOpFetcher} />
6060
)).to.not.throw();
6161
});
6262

6363
it('should not throw error if schema missing and query provided', () => {
64-
expect(() => renderIntoDocument(
64+
expect(() => ReactTestRenderer.create(
6565
<GraphiQL fetcher={noOpFetcher} query="{}" />
6666
)).to.not.throw();
6767
});
6868

6969
it('defaults to the built-in default query', () => {
70-
const graphiQL = renderIntoDocument(<GraphiQL fetcher={noOpFetcher} />);
71-
expect(graphiQL.state.query).to.include('# Welcome to GraphiQL');
70+
const graphiQL = ReactTestRenderer.create(
71+
<GraphiQL fetcher={noOpFetcher} />
72+
);
73+
expect(graphiQL.getInstance().state.query)
74+
.to.include('# Welcome to GraphiQL');
7275
});
7376

7477
it('accepts a custom default query', () => {
75-
const graphiQL = renderIntoDocument(
78+
const graphiQL = ReactTestRenderer.create(
7679
<GraphiQL
7780
fetcher={noOpFetcher}
7881
defaultQuery='GraphQL Party!!'
7982
/>
8083
);
81-
82-
expect(graphiQL.state.query).to.equal('GraphQL Party!!');
84+
expect(graphiQL.getInstance().state.query).to.equal('GraphQL Party!!');
8385
});
8486
});

src/utility/CodeMirrorSizer.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
* LICENSE-examples file in the root directory of this source tree.
77
*/
88

9-
import ReactDOM from 'react-dom';
10-
11-
129
/**
1310
* When a containing DOM node's height has been altered, trigger a resize of
1411
* the related CodeMirror instance so that it is always correctly sized.
@@ -20,7 +17,7 @@ export default class CodeMirrorSizer {
2017

2118
updateSizes(components) {
2219
components.forEach((component, i) => {
23-
const size = ReactDOM.findDOMNode(component).clientHeight;
20+
const size = component.getClientHeight();
2421
if (i <= this.sizes.length && size !== this.sizes[i]) {
2522
component.getCodeMirror().setSize();
2623
}

0 commit comments

Comments
 (0)