Skip to content

Instantly share code, notes, and snippets.

import HomePage from './HomePage.jsx';
import AboutPage from './AboutPage.jsx';
import UserPage from './UserPage.jsx';
import FourOhFourPage from './FourOhFourPage.jsx';
const PAGES = {
home: HomePage,
about: AboutPage,
user: UserPage,
};
class SignInModal extends Component {
componentDidMount() {
this.InputComponent.focus();
}
render() {
return (
<div>
<label>User name: </label>
<Input
class Input extends Component {
focus() {
this.el.focus();
}
render() {
return (
<input
ref={el=> { this.el = el; }}
/>
@somebody32
somebody32 / Readme.md
Created September 12, 2015 14:24
How to convert multiline vars into separate let/const declarations

You can convert js-code like this:

var a = '1',
    b,
    c = '2';

into

Name of thing Sorta like... Mounted? Can you even setState? What would you say... ya do here?
constructor initialize() nope nope init stuff NO side effects
componentWillMount beforeDomReady() nope yeah but don't Only needed in createClass now use constructor for most things
render render nope please no render stuff and don't set any state please
componentDidMount domReady() yup yup DOM is a go init jQuery plugins dispatch stuff
componentWillReceiveProps onChange() yup yup
@divyanshu013
divyanshu013 / .zshrc
Last active October 10, 2018 08:00
My zsh config
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/home/div/.oh-my-zsh"
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
@Sam1301
Sam1301 / RerenderTest.js
Last active January 2, 2019 11:04 — forked from joshma/WhyDidYouUpdateMixin.js
Test duplicate renders of your components with this HOC
// originally implemented as a mixin,
// taken from https://gist.github.com/joshma/6753333dd38a6010f9a6#file-whydidyouupdatemixin-js
// modified to make a higher-order component
/* eslint-disable no-console */
import _ from 'underscore';
import React, { Component, PureComponent } from 'react';
function isRequiredUpdateObject(o) {
return Array.isArray(o) || (o && o.constructor === Object.prototype.constructor);
function injectGitFileStatus()
{
const timeout = 5000;
const addedColor = "#8dc149";
const modifiedColor = "#cbcb41";
const stagedColor = "#ca2820";
const ignoredOpacity = "0.4";
const explorer = document.getElementById("workbench.view.explorer");
if (explorer)
@divyanshu013
divyanshu013 / .hyper.js
Last active April 5, 2019 11:54
My Hyper config
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// Choose either "stable" for receiving highly polished,
// or "canary" for less polished but more frequent updates
updateChannel: 'canary',
dialog {
position: fixed;
top: 50%;
left: 50%;
right: auto;
padding: 30px;
transform: perspective(500px) translate(-50%, -50%);
background: linear-gradient(to bottom, #FFF, #F4F4F4) #FFF;
border: none;
border-radius: 3px;