relay-tools / relay-hooks

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

support relay v16 + refactor useForceUpdate + react v18 strict #268

Closed morrys closed 5 months ago

morrys commented 6 months ago

Include:

morrys commented 6 months ago

Hi @gkaindl, @eMerzh, @Lalitha-Iyer, I just released version 9.0.0-rc.3 Your feedback would be very useful as in this release I added the optimization of useForceUpdate in order to manage the forceUpdate carried out after rendering but before the actual mount. And a change to useQuery and useOssFragment to handle double rendering in development mode caused by react strict (non-production issue)

I also updated the example project https://github.com/relay-tools/relay-hooks/tree/master/examples/relay-hook-example/pagination-nextjs-ssr to the latest releases of nextjs, relay and react in strict mode.

eMerzh commented 6 months ago

@morrys thaaanks :) the forceUpdate seems to be good from here... but i still have #263 not sure if it was fixed in earlier version or not 🤔

morrys commented 6 months ago

@eMerzh very curious, I integrated into this PR the other one where you didn't have the problem https://github.com/relay-tools/relay-hooks/pull/256#issuecomment-1842513759

did you run relay-compiler again?

eMerzh commented 6 months ago

i'm really really sorry, yeah it seems i didn't test properly or soemthing change?

anyways, i tried to dig it ... and using usePagination + loadPrevious(10)

with a fragment beeing @refetchable on a Node ... make it break..

https://github.com/relay-tools/relay-hooks/pull/268/files#diff-3478363f24e7381f9b3f144c18b1c2f8f5f1dc73c968d65c4ef9da948b6d6f2aR574 identifierInfo is null there... but if i take refetchMetadata instead... it sees to go further and identifierQueryVariableName doesn't seems to exists? 🤔

morrys commented 6 months ago

It seems like a problem with the files generated by the compiler or different versions of relay-runtime.

Do you check in the generated file if you have this?

"refetch": {
       "connection": {
         "forward": {
           "count": "count",
           "cursor": "after"
         },
         "backward": null,
         "path": (v0/*: any*/)
       },
       "fragmentPathInResult": [
         "node"
       ],
       "operation": require('./ReactRelayPaginationContainerUserFragmentRefetchQuery.graphql'),
       "identifierInfo": {
         "identifierField": "id",
         "identifierQueryVariableName": "id"
       }
     }
eMerzh commented 6 months ago

omg 😮‍💨 🤦 ... my compiler stayed on 15.0.0 ... after fixing it, everything is good to go 👏

Lalitha-Iyer commented 6 months ago

Verified relay-hooks@9.0.0-rc.3 with relay-runtime@16.0.0 and relay-compiler@^16.0.0 on our code base. Don't see any functional or performance issues. Thanks for tagging me !

morrys commented 6 months ago

Perfect, as soon as I can I'll merge and release version 9.0.0 :)

Thanks you all