Skip to content

Instantly share code, notes, and snippets.

@mauricedb
Last active November 11, 2016 16:59
Show Gist options
  • Save mauricedb/e753646ba915a5a9038204339957c466 to your computer and use it in GitHub Desktop.
Save mauricedb/e753646ba915a5a9038204339957c466 to your computer and use it in GitHub Desktop.
import React, { PropTypes } from 'react';
import LoginPage from './login-page';
import PlayingMovie from './playing-movie';
import MainPage from './main-page';
const App = ({ user, movies, playing, loginAsUser, startPlaying, stopPlaying }) => {
let component = null;
if (!user) {
component = <LoginPage loginAsUser={loginAsUser} />;
} else if (playing) {
component = <PlayingMovie movie={playing} stopPlaying={stopPlaying} />;
} else {
component = <MainPage user={user} movies={movies} startPlaying={startPlaying} />;
}
return (
<div className="container">
{component}
</div>
);
};
App.propTypes = {
user: PropTypes.object,
movies: PropTypes.array,
playing: PropTypes.object,
loginAsUser: PropTypes.func.isRequired,
startPlaying: PropTypes.func.isRequired,
stopPlaying: PropTypes.func.isRequired,
};
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment