pedronauck/react-adopt

Avoiding prop type fail?

danielmahon opened this issue · 1 comments

react-apollo complains about a prop-type failure on children when doing:

const Graphs = adopt({
  query: <Query query={USER_LEAGUES} />,
  join: <Mutation mutation={JOIN_USER_LEAGUE} />,
  quit: <Mutation mutation={QUIT_USER_LEAGUE} />,
});

is there a better solution than this?

const Graphs = adopt({
  query: ({ render }) => <Query query={USER_LEAGUES}>{render}</Query>,
  join: ({ render }) => (
    <Mutation mutation={JOIN_USER_LEAGUE}>{render}</Mutation>
  ),
  quit: ({ render }) => (
    <Mutation mutation={QUIT_USER_LEAGUE}>{render}</Mutation>
  ),
});

Or am I doing something wrong 😬 ?

For sure @danielmahon, in this case is better using render parameter