relay-tools / relay-hooks

Use Relay as React hooks
https://relay-tools.github.io/relay-hooks/docs/relay-hooks.html
MIT License
542 stars 56 forks source link

useFragment returns `unknown` type #158

Closed MoSattler closed 3 years ago

MoSattler commented 3 years ago

useFragment does not work with typescript relay.

In this case, the type of user is unknown.

interface Props {
  user: MyComponent_user;
}

const MyComponent = (props: Props) => {
  const user = useFragment(fragmentSpec, props.user);
  return null
}
morrys commented 3 years ago

hi @MoSattler, as you can see in the documentation and / or sample project, you must use the type of the key.