react-flow-types
A small collection of flow type definitions for working with React components
Last updated 8 years ago by ariaminaei .
MIT · Original npm · Tarball · package.json
$ npm install react-flow-types 
SYNC missed versions from official npm registry.

react-flow-types

Build Status npm downloads License Gitter

Note

Most of the types that used to be in this package now have equivalents in flow@0.53, so I'm deprecating them. The most important type that still remains is HigherOrderComponent. If you come up with more useful types for react, feel free to submit a PR :)

Usage

$ npm install --save-dev react-flow-types

HigherOrderComponent<RequiredProps, ProvidedProps>

The generic type of a higher-order component. A HigherOrderComponent always provides a set of props to the inner component, and requires another set of props to be passed to it.

Example:

import type {HigherOrderComponent} from 'react-flow-types'

type RequiredProps = {
  name: string,
}

type ProvidedProps = {
  input: {
    value: mixed,
    onChange: Function,
  },
}

// The hoc:
const asField = (): HigherOrderComponent<RequiredProps, ProvidedProps> => (component): any => {
  const FinalComponent = ({name, ...rest}) =>
    <ReduxFormField name={name} component={component} props={rest} />;

  hoistNonReactStatics(FinalComponent, component)

  FinalComponent.displayName =
    `asField(${component.displayName || component.name || 'Component'})`

  return FinalComponent
}

const Input = ({input}) => <input type="text" {...input} />
const WrapperInput = asField(Input)

const element = <WrappedInput name="email" />

Current Tags

  • 0.2.0-beta.6                                ...           latest (7 years ago)

8 Versions

  • 0.2.0-beta.6                                ...           7 years ago
  • 0.2.0-beta.5                                ...           7 years ago
  • 0.2.0-beta.4                                ...           7 years ago
  • 0.2.0-beta.3                                ...           7 years ago
  • 0.2.0-beta.2                                ...           7 years ago
  • 0.2.0-beta.1                                ...           7 years ago
  • 0.1.1                                ...           8 years ago
  • 0.1.0                                ...           8 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (3)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE