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

Set static #678

wants to merge 2 commits into from

Conversation

istarkov
Copy link
Contributor

ref #671

from what I see it will be impossible to make setStatic HOC work with compose, as it breaks the usual definition of HOC as a function of ComponentType<A> => ComponentType<B> into something like ComponentType<A> => { staticProp: type } & ComponentType<B>
I don't think this can be made composable in flowtype somehow.

So here is changed setStatic definition which would allow you to type it like below

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'} />

@istarkov istarkov self-assigned this May 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant