Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

Set static #678

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/packages/recompose/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.27.0
0.27.1
13 changes: 12 additions & 1 deletion src/packages/recompose/__tests__/types/test_statics.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-unused-vars, no-unused-expressions, arrow-body-style */
/* @flow */
import React from 'react'
import * as React from 'react'
import {
compose,
withProps,
Expand Down Expand Up @@ -53,3 +53,14 @@ setPropTypes(1)
setStatic(1, 'world')

const EnhancedComponent = enhacer(Comp)

const Component = ({ x, y }) => `${x} ${y}`

const Out: React.ComponentType<{ x: string }> = compose(
withProps(({ x }) => ({ y: x }))
)(Component)

const OutStatic = setStatic('name', 'Ivan')(Out)
OutStatic.name = 'hello'

const xx = () => <OutStatic x={'1'} />
6 changes: 5 additions & 1 deletion src/packages/recompose/index.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ declare export function branch<Base, Enhanced>(
): HOC<Base, Enhanced>

// test_statics
declare export function setStatic<A>(key: string, value: any): HOC<A, A>
declare export function setStatic<A, K: string, V: mixed>(
key: K,
value: V
): (a: React$ComponentType<A>) => { [K]: V } & React$ComponentType<A>

declare export function setPropTypes<A>(propTypes: Object): HOC<A, A>
declare export function setDisplayName<A>(displayName: string): HOC<A, A>

Expand Down