This file contains hidden or 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
const Index = () => ( | |
<div> | |
<p>Hello Server Side Rendered React App from Google Cloud Front</p> | |
</div> | |
) | |
export default Index |
This file contains hidden or 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
const next = require('next') | |
const app = next({ dev: false }) | |
const handle = app.getRequestHandler() | |
module.exports.handler = (req, res) => { | |
return app.prepare() | |
.then(() => handle(req, res)) | |
.catch(ex => { | |
console.error(ex.stack) |
This file contains hidden or 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
const next = require('next') | |
const app = next({ dev: false }) | |
const handle = app.getRequestHandler() | |
const slasher = handler => (req, res) => { | |
if (req.url === '') { | |
req.url = '/' | |
} |
This file contains hidden or 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
class Counter extends React.Component { | |
state = { | |
count: 0 | |
} | |
increase = () => { | |
this.setState({count: this.state.count + 1}) | |
} | |
render () { |
This file contains hidden or 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
const increaseFn = state => ({count: state.count + 1}) | |
class Counter extends React.Component { | |
state = { | |
count: 0 | |
} | |
increase = () => { | |
this.setState(increaseFn) | |
} |
This file contains hidden or 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
class FileUploader extends Component { | |
static propTypes = { | |
uploadingFile: PropTypes.object, | |
uploadProgress: PropTypes.object, | |
cancelled: PropTypes.bool, | |
completed: PropTypes.bool, | |
uploadFile: PropTypes.func.isRequired, | |
cancelUpload: PropTypes.func.isRequired, | |
retryUpload: PropTypes.func.isRequired | |
} |
This file contains hidden or 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 axios from 'axios' | |
export const INIT_UPLOADER = 'INIT_UPLOADER' | |
export const START_UPLOADING = 'START_UPLOADING' | |
export const UPLOAD_PROGRESS = 'UPLOAD_PROGRESS' | |
export const UPLOAD_SUCCESS = 'UPLOAD_SUCCESS' | |
export const CLEAR_FILE_SELECTION = 'CLEAR_FILE_SELECTION' | |
export const CANCELLED_UPLOAD = 'CANCELLED_UPLOAD' | |
export const initialState = { |
This file contains hidden or 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' | |
const connect = (component, actionCreator, initialState) => { | |
const attach = instance => ({ | |
set: fn => new Promise(resolve => instance.setState(fn, resolve)), | |
get: () => instance.state | |
}) | |
return class Connected extends Component { | |
constructor(props, context) { |
This file contains hidden or 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 PropTypes from 'prop-types' | |
import FileDrop from './FileDrop' | |
import FileUploadProgress from './FileUploadProgress' | |
import {createActions, initialState} from './uploader' | |
import connect from '../connect' | |
class FileUploader extends Component { | |
static propTypes = { | |
uploadingFile: PropTypes.object, |
This file contains hidden or 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 expect from 'must' | |
import sinon from 'sinon' | |
import mustSinon from 'must-sinon' | |
import { | |
uploadFileReducer, | |
createActions, | |
initialState, | |
INIT_UPLOADER, | |
START_UPLOADING | |
} from '../../../components/FileUploader/uploader' |