Skip to content

Instantly share code, notes, and snippets.

// @flow
import React, { type ComponentType } from 'react';
import Form from './Form';
import { CreateButton } from './buttons';
import TextInputBig from './TextInputBig';
import { FormattedMessage } from 'react-intl';
import Text from './Text';
import Set from './Set';
import CreateWebMutation from '../mutations/CreateWebMutation';
import withMutation, { getClientMutationId } from './withMutation';
// @flow
import React from 'react';
import * as validation from '../lib/validation';
import Text, { type TextProps } from './Text';
import { FormattedMessage } from 'react-intl';
type Props = TextProps & {
error: ?validation.ValidationError,
};
// @flow
import isEmail from 'validator/lib/isEmail';
type AlreadyExists = { type: 'alreadyExists' };
type Email = { type: 'email' };
type MaxLength = { type: 'maxLength', maxLength: number };
type MinLength = { type: 'minLength', minLength: number };
type Required = { type: 'required' };
type RequiredAgree = { type: 'requiredAgree' };
type WrongPassword = { type: 'wrongPassword' };
@steida
steida / withMutation.js
Created September 9, 2017 12:25
Oh Flow, why you are so mean to me.
// @flow
import React, { type ComponentType } from 'react';
import type { Commit, Environment } from '../types';
import PropTypes from 'prop-types';
const withMutation = <Props: {}, Variables, Response>(
Component: ComponentType<
{
mutate: (
commit: Commit<Variables, Response>,
// @flow
import React from 'react';
import Form from './Form';
import { CreateButton } from './buttons';
import TextInputBig from './TextInputBig';
import { FormattedMessage } from 'react-intl';
import Text from './Text';
import Set from './Set';
import nameToDomain from '../lib/nameToDomain';
import { createFragmentContainer, graphql } from 'react-relay';
// @flow
// temp is a wrapper for temporary values which need to be stored in local
// storage but revived with a different value.
// For example, form disabled state, which needs to be stored because cross tab
// sync, but revived with a false value, otherwise form would be frozen forever.
// It can be used for any value of course.
// Session only value. If tempId is not current then false is returned.
// const value = createTemp(true, false);
<link rel="alternate" hreflang="cs" href="http://cs.example.com/" />
@steida
steida / forms.jsx
Last active September 17, 2019 09:10
// @flow
import type { State } from '../types';
import Form from '../components/form';
import TextInput from '../components/text-input';
import { connect } from 'react-redux';
import { setUserForm } from '../lib/forms/actions';
const UserForm = ({ id, user, setUserForm }) => {
// If you know how to type it better, please let me know.
const onChange = (prop: $Keys<typeof user>) => state => {
// @flow
import type { Action, FormsState } from '../../types';
import { reject, isNil } from 'ramda';
const initialState = {
user: {
initialState: {
name: '',
description: '',
likesCats: false,
// @flow
import type { Action, Id, UserForm } from '../../types';
export const setUserForm = (id: Id, state: ?UserForm): Action => ({
type: 'SET_USER_FORM',
id,
state,
});