recompose
recompose copied to clipboard
Set static
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'} />