Skip to content

Commit b997ea0

Browse files
committed
Access the location object only from the root component
1 parent abccc0a commit b997ea0

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

client/app.jsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import ReactDOM from 'react-dom';
33
import 'bootstrap/scss/bootstrap.scss';
44
import './app.scss';
55
import 'font-awesome/css/font-awesome.css';
6-
import queryString from 'query-string';
76
import 'babel-regenerator-runtime';
87

98
import CodeMirror from 'codemirror';
@@ -50,10 +49,9 @@ class Editor extends React.Component {
5049
};
5150

5251
this.codeMirror = CodeMirror.fromTextArea(this.textareaNode, options);
53-
const params = new URLSearchParams(window.location.search);
5452

55-
if (params.has('query')) {
56-
this.codeMirror.setValue(params.get('query'));
53+
if (this.props.query !== null) {
54+
this.codeMirror.setValue(this.props.query);
5755
}
5856
}
5957
}
@@ -69,7 +67,7 @@ class QueryBox extends React.Component {
6967
<div className="container-fluid">
7068
<form action="./sparql">
7169
<div className="form-group">
72-
<Editor />
70+
<Editor query={this.props.query} />
7371
</div>
7472
<button className="btn btn-primary">
7573
Run Query
@@ -84,7 +82,7 @@ class QueryBox extends React.Component {
8482
class MainComponent extends React.Component {
8583
constructor() {
8684
super(...arguments);
87-
this.query = queryString.parse(window.location.search).query || '';
85+
this.query = new URLSearchParams(window.location.search).get('query');
8886
}
8987

9088
render() {

0 commit comments

Comments
 (0)