Skip to content

Instantly share code, notes, and snippets.

:⌉
=⌉
¦-) as opposed to |
⍥ om nom nom
import React, {
useEffect,
createContext,
FunctionComponent,
useRef,
MutableRefObject,
useCallback,
useContext,
useReducer,
Reducer,
import throttle from 'lodash.throttle';
import React, { Dispatch, SetStateAction, useContext } from 'react';
import WasRenderedContext from '../contexts/WasRenderedContext';
type Key = 'darkMode' | 'tasks' | 'email' | 'version';
type DarkMode = boolean;
interface TaskText {
leaves: Array<{ text: string }>;
export const validateEmailAndPassword = (validate, fields) => validate(fields)
.prop('email')
.required()
.email()
.prop('password')
.required()
.simplePassword()
.promise;
@steida
steida / nearest.js
Created October 8, 2018 17:41
Get nearest day week date defined by week in month
/* @flow */
import React from 'react';
import { DayOfWeek, LocalDate, TemporalAdjusters } from 'js-joda';
import { FormattedDate } from 'react-intl';
import { ValidationError } from '../../common/lib/validation';
import { connect } from 'react-redux';
import { fields } from '../../common/lib/redux-fields';
import { orderCourse } from '../../common/courses/actions';
import {
Block,
@steida
steida / textinput.js
Created June 7, 2018 22:21
Textarea auto height for server side rendering
<TextInput
multiline
// value={value}
defaultValue={value}
onChange={this.handleChange}
placeholderTextColor={placeholderTextColor}
placeholder={intl.formatMessage(messages.placeholder)}
ref={this.inputRef}
style={[
theme.styles.editorTextInput,
# https://github.com/este/este/wiki/GraphQL
# https://www.prisma.io/features/data-modeling/
# The order of types and consistent relations names is probably a pattern.
type User {
id: ID! @unique
createdAt: DateTime!
updatedAt: DateTime!
email: String! @unique
@steida
steida / gist:b975439378980911ee4d
Last active March 20, 2018 15:37
I love Coffee React with dependency injection.
goog.provide 'app.react.App'
class app.react.App
###*
@param {app.Routes} routes
@param {app.react.Header} header
@param {app.react.Footer} footer
@param {app.react.pages.Home} home
@param {app.react.pages.EditSong} editSong
// @flow
import A from './A';
import ErrorPopup from './ErrorPopup';
import Box from './Box';
import Head from 'next/head';
import LoadingBar from './LoadingBar';
import MainNav from './MainNav';
import * as React from 'react';
import SwitchLocale from './SwitchLocale';
import Text from './Text';
// @flow
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
import type { Error as ErrorType } from '../lib/error';
import Text, { type TextProps } from './Text';
export const errorToMessage = (error: ErrorType) => {
switch (error.type) {
case 'required':
return (