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
function Quiz(props) { | |
function renderAnswerOptions(key,index) { | |
return ( | |
<AnswerOption | |
index ={index} | |
key={key.content} | |
answerContent={key.content} | |
answerType={key.type} |
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
var webpack = require('webpack'); | |
var path = require('path'); | |
var BUILD_DIR = path.resolve(__dirname, 'public/scripts'); | |
var APP_DIR = path.resolve(__dirname, 'src'); | |
var config = { | |
entry: { | |
app: [path.join(__dirname, 'src/app.js')], | |
vendor: [ |
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
var path = require('path'); | |
var webpack = require('webpack'); | |
module.exports = { | |
entry: './js/main.js', | |
output: { | |
path: path.resolve(__dirname, 'build'), | |
filename: 'main.bundle.js' | |
}, | |
module: { |
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"; | |
export default function asyncComponent(getComponent) { | |
class AsyncComponent extends Component { | |
static Component = null; | |
state = { Component: AsyncComponent.Component }; | |
componentWillMount() { | |
if (!this.state.Component) { | |
getComponent().then(Component => { | |
AsyncComponent.Component = Component |
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 * as Action from 'app/redux/actions'; | |
const RegisterPage = asyncComponent(() => | |
import('app/ui/auth/Register').then(module => module.default) | |
) | |
const LoginPage = asyncComponent(() => | |
import('app/ui/auth/Login').then(module => module.default) | |
) | |
AdminFormComponent from 'app/components/dashboard/formPage'; |
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
//-------------------1-----------------------// | |
shouldComponentUpdate(nextProps) { | |
// expensive! | |
return isDeepEqual(this.props, nextProps); | |
} | |
//-------------------2-------------------------// | |
// super fast - all you are doing is checking references! | |
shouldComponentUpdate(nextProps) { | |
return isObjectEqual(this.props, nextProps); | |
} |
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 isObjectEqual = (obj1, obj2) => { | |
if(!isObject(obj1) || !isObject(obj2)) { | |
return false; | |
} | |
// are the references the same? | |
if (obj1 === obj2) { | |
return true; | |
} |
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
shouldComponentUpdate (nextProps) { | |
// have any of the items changed? | |
if(!isArrayEqual(this.props.items, nextProps.items)){ | |
return true; | |
} | |
// everything from here is horrible. | |
// if interaction has not changed at all then when can return false (yay!) | |
if(isObjectEqual(this.props.interaction, nextProps.interaction)){ | |
return false; |
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
var webpack = require('webpack'); | |
var path = require('path'); | |
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; | |
var BUILD_DIR = path.resolve(__dirname, 'public/scripts'); | |
var APP_DIR = path.resolve(__dirname, 'app'); | |
var config = { | |
entry: { | |
app: [path.join(__dirname, 'app/app.js')], |
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
new webpack.optimize.DedupePlugin(), | |
new webpack.optimize.UglifyJsPlugin({ | |
mangle: true, | |
compress: { | |
warnings: false, // Suppress uglification warnings | |
pure_getters: true, | |
unsafe: true, | |
unsafe_comps: true, | |
screw_ie8: true | |
}, |