Skip to content

Commit 4235b4c

Browse files
committed
remove mobx from search input and results
1 parent f6f02e1 commit 4235b4c

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

web/src/App.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ export default observer(class App extends Component {
2121
return (
2222
<MuiThemeProvider>
2323
<div>
24-
<SearchInput colors={this.props.colors}/>
25-
<SearchResults colors={this.props.colors}/>
24+
<SearchInput query={this.props.colors.query}
25+
onQueryUpdate={value => this.props.colors.updateQuery(value)}
26+
onSubmit={() => this.props.colors.search()}
27+
/>
28+
<SearchResults colors={this.props.colors.results.slice()}/>
2629
</div>
2730
</MuiThemeProvider>
2831
);

web/src/SearchInput.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import React, {Component} from 'react';
22
import {TextField} from 'material-ui';
3-
import {observer} from 'mobx-react';
43

5-
export default observer(class SearchInput extends Component {
4+
export default class SearchInput extends Component {
65
static propTypes = {
7-
colors: React.PropTypes.object.isRequired
6+
query: React.PropTypes.string.isRequired,
7+
onSubmit: React.PropTypes.func.isRequired,
8+
onQueryUpdate: React.PropTypes.func.isRequired
89
};
910

1011
handleKeyDown = (event) => {
1112
const ENTER_KEY = 13;
1213
if (event.keyCode === ENTER_KEY) {
1314
event.preventDefault();
14-
this.props.colors.search();
15+
this.props.onSubmit();
1516
}
1617
};
1718

@@ -20,9 +21,9 @@ export default observer(class SearchInput extends Component {
2021
<TextField hintText="Search..."
2122
floatingLabelFixed={true}
2223
fullWidth={true}
23-
value={this.props.colors.query}
24-
onChange={(event, value) => this.props.colors.updateQuery(value)}
24+
value={this.props.query}
25+
onChange={(event, value) => this.props.onQueryUpdate(value)}
2526
onKeyDown={this.handleKeyDown}/>
2627
)
2728
}
28-
});
29+
}

web/src/SearchResults.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import React, {Component} from 'react';
22
import {List, ListItem, Divider} from 'material-ui'
3-
import {observer} from 'mobx-react';
43

5-
export default observer(class SearchResults extends Component {
4+
export default class SearchResults extends Component {
65
static propTypes = {
7-
colors: React.PropTypes.object.isRequired
6+
colors: React.PropTypes.array.isRequired
87
};
98

109
render() {
11-
const listItems = this.props.colors.results.map((color, index) => {
10+
const listItems = this.props.colors.map((color, index) => {
1211
return (
1312
<div key={`color-div-${index}`}>
1413
<ListItem key={`color-${index}`} primaryText={color.name} style={{backgroundColor: color.hex} }/>
@@ -23,4 +22,4 @@ export default observer(class SearchResults extends Component {
2322
);
2423
}
2524

26-
});
25+
}

0 commit comments

Comments
 (0)