Skip to content

Instantly share code, notes, and snippets.

@awareness481
Created May 1, 2018 15:35
Show Gist options
  • Save awareness481/8207829ab0d02ae9b575e6a16e50b317 to your computer and use it in GitHub Desktop.
Save awareness481/8207829ab0d02ae9b575e6a16e50b317 to your computer and use it in GitHub Desktop.
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>
);
}
}
import React from 'react';
import ReactDOM from 'react-dom';
import MovieApp from './components/MovieApp';
ReactDOM.render(<MovieApp />, document.getElementById('app'));
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