Skip to content

Instantly share code, notes, and snippets.

View nesbtesh's full-sized avatar

Nessim Btesh nesbtesh

  • Boston
View GitHub Profile
@nesbtesh
nesbtesh / Generators.js
Created August 17, 2016 14:49
Generators ES6
function* getStockValue() {
var entry1 = yield request('http://myrl.com/stock/key');
var data1 = JSON.parse(entry1);
var entry2 = yield request('http://myurl/stock/value');
var data2 = JSON.parse(entry2);
}
getJSON(url, function(response) {
getJSON(url, function(response) {
console.log(response);
});
});
@nesbtesh
nesbtesh / createConstants.js
Created August 24, 2016 13:31
Create Redux Constants
export function createConstants(...constants) {
return constants.reduce((acc, constant) => {
acc[constant] = constant;
return acc;
}, {});
}
@nesbtesh
nesbtesh / reducer.js
Created August 24, 2016 13:34
Usage of createReducer.js
import {createReducer} from '../../utils';
// Add the following for IE compatability
Object.assign = Object.assign || require('object-assign');
const initialState = {
'count': 0,
'receiving': false,
'pages': 0,
'documents': []
};
@nesbtesh
nesbtesh / renderIfExample.js
Last active August 26, 2016 01:28
Usage of render if
import renderIf from '../utils/renderif'
export default class RenderIfExample extends Component {
render() {
var isTrue = true;
return (
<div>
{renderIf(isTrue)(
<h1>I am being rendered</h1>
export default class BindFunctionExample extends React.Component {
constructor() {
super();
this.state = {
hidden: true,
};
this.toggleHidden = this.toggleHidden.bind(this);
}
toggleHidden() {
"scripts": {
"eslint": "eslint",
"lint": "eslint --config .eslintrc.json --format compact .",
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack --debug",
"buildProduction": "webpack --progress -p",
"deployMac": "./build_helpers/buildDist.sh",
"deployWin": "./build_helpers/buildDist.exe",
"dev": "webpack-dev-server --content-base src --inline --hot",
"devhttps": "webpack-dev-server --content-base src --inline --hot --https",
@nesbtesh
nesbtesh / buildDist.sh
Created September 20, 2016 19:01
compile React with Webpack executable
set -e
PATH=$(npm bin):$PATH
rm -rf ./dist
NODE_ENV=production
webpack --progress -p
COMPRESS=1 webpack
npm run deploy
@nesbtesh
nesbtesh / BadLoginExample.js
Last active November 19, 2016 19:10
Bad Login Example
import React from "react";
export default class LoginForm extends React.Component {
render(){
return(
<form>
<p>Login</p>
<div className="label-input">
<label>Email Address</label>
import React from "react";
import LabelInput from "./LabelInput";
export default class LoginForm extends React.Component {
render(){
const {email, password, onSubmit, onChange} = this.props;
return(
<form>
<p>Login</p>