Skip to content

Commit 6f1be2b

Browse files
ethankoch4germanattanasio
authored andcommitted
fix: Hot fix syntax non english (#39)
This fixes the issue of not rendering any responses for non-English languages due to the attempt to access `tokens` on the `response.syntax` object, which is undefined if the language does not support `syntax`.
1 parent 5cab527 commit 6f1be2b

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

views/Output/Output.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function Output(props) {
8282
</Pane>
8383
<Pane label="Syntax">
8484
<Syntax
85-
data={props.data.results.syntax.tokens}
85+
data={props.data.results.syntax}
8686
language={languages.getLanguageName(props.language)}
8787
/>
8888
</Pane>

views/Output/Syntax.jsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@ export default React.createClass({
5858
displayName: 'Syntax',
5959

6060
propTypes: {
61-
data: PropTypes.arrayOf(PropTypes.shape({
62-
text: PropTypes.string,
63-
part_of_speech: PropTypes.string,
64-
lemma: PropTypes.string,
65-
})),
61+
data: PropTypes.shape({
62+
tokens: PropTypes.arrayOf(PropTypes.shape({
63+
text: PropTypes.string,
64+
part_of_speech: PropTypes.string,
65+
lemma: PropTypes.string,
66+
})),
67+
}),
6668
language: PropTypes.string,
6769
},
6870

@@ -78,7 +80,7 @@ export default React.createClass({
7880
},
7981

8082
onWaypoint() {
81-
if (this.state.visibleItems < this.props.data.length) {
83+
if (this.state.visibleItems < this.props.data.tokens.length) {
8284
setTimeout(() => {
8385
this.setState({
8486
visibleItems: this.state.visibleItems + 10,
@@ -98,12 +100,12 @@ export default React.createClass({
98100
onShowJson={this.toggleJson}
99101
>
100102
{console.log(this.props.data)}
101-
{this.props.data && this.props.data.length > 0 ? (
103+
{this.props.data && this.props.data.tokens && this.props.data.tokens.length > 0 ? (
102104
<div>
103105
<Table
104106
columns={['Token', 'Part of Speech', 'Lemma']}
105107
theme={tableTheme}
106-
data={this.props.data.reduce((acc, item) => {
108+
data={this.props.data.tokens.reduce((acc, item) => {
107109
acc.push({ Token: item.text,
108110
'Part of Speech': item.part_of_speech,
109111
Lemma: item.lemma });

0 commit comments

Comments
 (0)