Created
May 1, 2018 15:35
-
-
Save awareness481/8207829ab0d02ae9b575e6a16e50b317 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
export default class Action extends React.Component { | |
constructor(props) { | |
super(props); | |
this.handleAction = this.handleAction.bind(this); | |
} | |
handleAction (e) { | |
e.preventDefault(); | |
// const movie = e.target.elements.movie.value; | |
const query = e.target.query.value; | |
} | |
render() { | |
return ( | |
<div> | |
<form onSubmit={this.handleAction}> | |
<input type='text' name='query'/> | |
</form> | |
</div> | |
); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import MovieApp from './components/MovieApp'; | |
ReactDOM.render(<MovieApp />, document.getElementById('app')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import NewMovies from './NewMovies'; | |
import Action from './Action'; | |
export default class MovieApp extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
movie: "", | |
movieSelected: false | |
} | |
this.handleAction = this.handleAction.bind(this); | |
} | |
handleAction(query) { | |
if (query) { | |
this.setState(() => { movie: query }); | |
} | |
} | |
componentDidUpdate() { | |
console.log('update!'); | |
} | |
render() { | |
return ( | |
<div> | |
<Action | |
handleAction={this.handleAction} | |
/> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment