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

fix(types): RelayEnvironmentProvider should accept IEnvironment #266

Closed ianobermiller closed 10 months ago

ianobermiller commented 11 months ago

RelayEnvironmentProvider current accepts only the type Environment, which is actually the default export, or RelayModernEnvironment. Because of some funny naming by relay-runtime, we actually want "any environment", which is IEnvironment. This allows us to pass in a mock environment as opposed to a fully-fledged RelayModernEnvironment.

I also converted the component to a function for consistency and removed the generic since it isn't necessary.

morrys commented 10 months ago

hi @ianobermiller, I'm sorry if I only replied now because I hadn't seen the pr :/

How about changing it like this?

export const RelayEnvironmentProvider = function <TEnvironment extends IEnvironment = Environment>(props: {

So the extends is the only thing that changes, this should solve your problem too.

ianobermiller commented 10 months ago

Yes, that would work, but the generic isn't necessary since there are no other props using it.

morrys commented 10 months ago

released with relay-hooks v9.0.0