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
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
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
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
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
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
class App extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
counter: 0, | |
questionId: 1, | |
question: '', | |
answerOptions: [], |
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 quizQuestions = [ | |
{ | |
question: "What franchise would you rather play a game from?", | |
answerindex : 1, | |
answers: [ | |
{ | |
type: "IBM", | |
content: "Halo", | |
answer : 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
export default class shoppingList { | |
loaded : boolean = true | |
products : product[]; | |
private subscription : Subscription; | |
constructor(private _cartService : cartService) {} | |
ngOnInit() { | |
// this.loaderService.show(); | |
this.subscription = this._cartService.CartState | |
.subscribe((state : CartState) => { | |
this.products = state.products; |
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
export default class shoppingCartItem { | |
@Input()product : product; | |
constructor(private _cartService : cartService) {} | |
AddProduct(_product : product) { | |
_product.added = true; | |
this | |
._cartService | |
.addProduct(_product); | |
} | |
RemoveProduct(_product : product) { |