Skip to content

Instantly share code, notes, and snippets.

View nesbtesh's full-sized avatar

Nessim Btesh nesbtesh

  • Boston
View GitHub Profile
@nesbtesh
nesbtesh / rederif.js
Last active November 20, 2016 00:06
React render if true
'use strict';
const isFunction = input => typeof input === 'function';
export default predicate => elemOrThunk =>
predicate ? (isFunction(elemOrThunk) ? elemOrThunk() : elemOrThunk) : null;
@nesbtesh
nesbtesh / DumbComponent.js
Last active November 20, 2016 22:01
Dumb Components in React
const DumbComponent = (props) => {
return (<div />);
}
var object1 = {color: "blue", size: 12};
var object2 = object1
object2.color = "red"
object1 === object2 //true
object3 = Object.assign({}, object1)
object3.color = "red"
object1 === object3 //false
@nesbtesh
nesbtesh / objectComparison.js
Created August 24, 2016 13:35
Object comparison JS
export const isObjectEqual = (obj1, obj2) => {
if(!isObject(obj1) || !isObject(obj2)) {
return false;
}
if (obj1 === obj2) {
return true;
}
const item1Keys = Object.keys(obj1).sort();
@nesbtesh
nesbtesh / webpack.cofig.js
Last active February 1, 2017 04:42
Webpack Configuration File
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require("path");
require("babel-polyfill");
module.exports = {
context: path.join(__dirname, "src"),
devtool: debug ? "inline-sourcemap" : null,
entry: ["babel-polyfill", "./" + path.join("js", "scripts.js")],
module: {
import Perf from 'react-addons-perf'
window.Perf = Perf
import React from "react";
import {parseUri} from "../../../utils";
const AutocompleteItem = (props) => {
const {props} = this;
const selectedClass = props.selected === true ? "selected" : "";
var path = parseUri(props.url).path;
path = path.length <= 0 ? props.url : "..." + path;
import React from "react";
import {parseUri} from "../../../utils";
export default class AutocompleteItem extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
if(
nextProps.url !== this.props.url ||
nextProps.selected !== this.props.selected
){
import React from "react";
export default class Tooltip extends React.Component {
state = {
visible: false,
imageStatus: null
}
handleImageLoaded = () => {
import {createReducer} from '../utils';
import {LOGIN_USER_REQUEST, LOGIN_USER_SUCCESS, LOGIN_USER_FAILURE, LOGOUT_USER} from '../constants';
import {pushState} from 'redux-router';
import jwtDecode from 'jwt-decode';
const initialState = {
token: null,
userName: null,
isAuthenticated: false,
isAuthenticating: false,