This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState, useRef, useCallback } from "react"; | |
| import Button from "./Button"; | |
| function App() { | |
| const [state, setState] = useState(""); | |
| const ref = useRef(state); | |
| const handleChange = useCallback(event => { | |
| ref.current = event.target.value; | |
| setState(event.target.value); | |
| }, []); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| document.body.style.paddingBottom = '250px'; | |
| const div = document.createElement('div'); | |
| Object.assign(div.style, { | |
| position: 'fixed', | |
| bottom: 0, | |
| left: 0, | |
| right: 0, | |
| height: '250px', | |
| opacity: 0.90, | |
| color: 'white', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const escapeRegex = /([^\\])\./g; | |
| export const normalizeToken = index => (str, prev) => { | |
| if ( | |
| typeof str === 'string' || | |
| typeof str === 'number' || | |
| typeof str === 'boolean') { | |
| const groups = prev.toString() | |
| .replace(escapeRegex, '$1¬') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .loader { | |
| color: inherit; | |
| display: inline-block; | |
| cursor: wait; | |
| } | |
| .loader > span { | |
| animation-name: blink; | |
| animation-duration: 1.4s; | |
| animation-iteration-count: infinite; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* eslint-disable react/prefer-stateless-function */ | |
| import React from 'react'; | |
| import { reduxForm, FieldArray, Field, FormSection } from 'redux-form'; | |
| import { TextField } from 'redux-form-material-ui'; | |
| const getDepth = (name) => { | |
| if (name) { | |
| const match = name.match(/children\[\d\]/g); | |
| if (match) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { Field, reduxForm } from 'redux-form'; | |
| import { AutoComplete, FlatButton } from 'material-ui'; | |
| // Component | |
| const mapError = ( | |
| { | |
| meta: { touched, error, warning } = {}, | |
| input, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as deepMerge from 'deepmerge'; | |
| import * as deepFreeze from 'deep-freeze'; | |
| function sealed(constructor: Function) { | |
| Object.seal(constructor); | |
| Object.seal(constructor.prototype); | |
| } | |
| @sealed | |
| export class StateObject<T> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Mixin } from './mixin'; | |
| import { EventEmitter } from 'events'; | |
| // Define .h | |
| export declare class EventEmittable { | |
| protected events: EventEmitter; | |
| } | |
| // Implement .cpp | |
| export const EventEmittableMixin = (mixin: Mixin) => class extends mixin { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class Bitwise { | |
| private _i: number; | |
| constructor(value: number) { | |
| this._i = value; | |
| } | |
| test(mask = 0x01) { | |
| return (mask ^ this._i) === 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class SmartCursor { | |
| private _cur: number; | |
| private _memorized: number; | |
| constructor(i: number = 0) { | |
| this._cur = i; | |
| this._memorized = i; | |
| } |