diff --git a/src/components/App.js b/src/components/App.js index c79b185..daa76c8 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -1,10 +1,13 @@ import React from 'react'; import './App.css'; - +import SearchStories from './SearchStories'; import Stories from './Stories'; const App = () =>
+
+ +
diff --git a/src/components/SearchStories.js b/src/components/SearchStories.js new file mode 100644 index 0000000..bc7c7df --- /dev/null +++ b/src/components/SearchStories.js @@ -0,0 +1,51 @@ +import React, { Component } from 'react'; +import { observable, action } from 'mobx'; +import { observer } from 'mobx-react'; +import Button from './Button'; + +@observer +class SearchStories extends Component { + @observable query = ''; + + constructor(props) { + super(props); + + this.onSubmit = this.onSubmit.bind(this); + this.onChange = this.onChange.bind(this); + } + + @action + onChange(event) { + const { value } = event.target; + this.query = value; + } + + @action + onSubmit(event) { + if (this.query) { + // TODO do API fetch stories + console.log(this.query); + + this.query = ''; + } + + event.preventDefault(); + } + + render() { + return ( +
+ + +
+ ); + } +} + +export default SearchStories; \ No newline at end of file