recompose icon indicating copy to clipboard operation
recompose copied to clipboard

Set static

Open istarkov opened this issue 6 years ago • 0 comments

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 avatar May 24 '18 17:05 istarkov