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
{ | |
"private": true, | |
"name": "preact-workshop", | |
"version": "0.0.0", | |
"license": "MIT", | |
"scripts": { | |
"start": "if-env NODE_ENV=production && npm run -s serve || npm run -s dev", | |
"build": "preact build", | |
"serve": "preact build && preact serve", | |
"dev": "preact watch", |
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, { PropTypes } from "react"; | |
import { connect } from "react-redux"; | |
import LoginPage from "./login-page"; | |
import PlayingMovie from "./playing-movie"; | |
import MainPage from "./main-page"; | |
import AjaxLoading from "./utils/ajax-loading"; | |
const AppPresentation = ({ user, hasMovies, playing }) => { | |
let component = null; |
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 { login } from "."; | |
describe("Actions", () => { | |
it("should create a LOGIN action", () => { | |
const action = login({ name: "Maurice" }); | |
expect(action).toEqual({ | |
type: "LOGIN", | |
payload: { | |
name: "Maurice" |
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 { createStore, applyMiddleware } from "redux"; | |
import { Provider } from "react-redux"; | |
import thunk from "redux-thunk"; | |
import AppPresentation from "./app-presentation"; | |
import reducers from "./reducers"; |
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
export const moviesLoaded = movies => ({ | |
type: "MOVIES-LOADED", | |
payload: movies | |
}); | |
export const loadMovies = () => | |
dispatch => | |
fetch("/movies.json") | |
.then(rsp => rsp.json()) | |
.then(movies => dispatch(moviesLoaded(movies))); |
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
export const moviesLoaded = movies => ({ | |
type: "MOVIES-LOADED", | |
payload: movies | |
}); | |
export const loadMovies = () => | |
dispatch => | |
fetch("/movies.json") | |
.then(rsp => rsp.json()) | |
.then(movies => dispatch(moviesLoaded(movies))); |
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 { createStore, applyMiddleware } from "redux"; | |
import { Provider } from "react-redux"; | |
import thunk from "redux-thunk"; | |
import AppContainer from "./app-container"; | |
import reducers from "./reducers"; |
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
export const moviesLoaded = movies => ({ | |
type: 'MOVIES-LOADED', | |
payload: movies, | |
}); | |
export const loadMovies = () => dispatch => | |
fetch('/movies.json') | |
.then(rsp => rsp.json()) | |
.then(movies => dispatch(moviesLoaded(movies))); |
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, { Component } from 'react'; | |
import AppPresentation from './app-presentation'; | |
class AppContainer extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
playing: null, | |
allMovies: null, |
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
export const login = user => ({ | |
type: 'LOGIN', | |
payload: user, | |
}); |