renatorib / react-powerplug

:electric_plug: Renderless Containers
https://renatorib.github.io/react-powerplug
MIT License
2.68k stars 101 forks source link

Wrong types with Flow and react-composer and compose #183

Closed FezVrasta closed 5 years ago

FezVrasta commented 5 years ago

If I do this:

<Composer
  components={[
    <Value key="test" initial={true} />,
  ]}
>

I get:

[flow] Cannot create `Value` element because: Either property `render` is missing in props [1] but exists in object type [2]. Or property `children` is missing in props [1] but exists in object type [3]. (References: [1] [2] [3])

if I do the same with other render-props components such as react-apollo's Query, it works just fine.

Is there any chance to see this fixed?

edit: actually it happens even with the react-powerplug Compose utility

TrySound commented 5 years ago

Render and children cannot be optional. Composability with type inference doesn't work yet. You may compose however you want without doubtful utilities.

const Composed = ({ children }) => (
  <Value>
    {dialog =>
      <Value>
        {mode =>
          children({ dialog, mode })
        }
      </Value>
    }
  </Value>
)