Skip to content

Instantly share code, notes, and snippets.

View tkssharma's full-sized avatar
🎯
only JS

codewithtkssharma tkssharma

🎯
only JS
View GitHub Profile
function Quiz(props) {
function renderAnswerOptions(key,index) {
return (
<AnswerOption
index ={index}
key={key.content}
answerContent={key.content}
answerType={key.type}
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: [
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: {
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
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';
//-------------------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);
}
const isObjectEqual = (obj1, obj2) => {
if(!isObject(obj1) || !isObject(obj2)) {
return false;
}
// are the references the same?
if (obj1 === obj2) {
return true;
}
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;
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')],
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
},