Skip to content

Instantly share code, notes, and snippets.

View tkssharma's full-sized avatar
🎯
only JS

codewithtkssharma tkssharma

🎯
only JS
View GitHub Profile
//-------------------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);
}
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';
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
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: {
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: [
function Quiz(props) {
function renderAnswerOptions(key,index) {
return (
<AnswerOption
index ={index}
key={key.content}
answerContent={key.content}
answerType={key.type}
class App extends Component {
constructor(props) {
super(props);
this.state = {
counter: 0,
questionId: 1,
question: '',
answerOptions: [],
var quizQuestions = [
{
question: "What franchise would you rather play a game from?",
answerindex : 1,
answers: [
{
type: "IBM",
content: "Halo",
answer : false
},
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;
export default class shoppingCartItem {
@Input()product : product;
constructor(private _cartService : cartService) {}
AddProduct(_product : product) {
_product.added = true;
this
._cartService
.addProduct(_product);
}
RemoveProduct(_product : product) {