Hooks - `useFragment` (sometimes) returns null when record is deleted
- Dominant language
- Rust
- Stars
- 19k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
Version: `react-relay@11.0.2`
Issue: the return value for `useFragment` is null in some circumstances. The types suggest that this should not occur.
Repro in the example TODO app:
https://codesandbox.io/s/usefragment-returns-null-6tynl?file=/src/Todo.tsx:1027-1035
https://user-images.githubusercontent.com/489896/121592515-c8106980-ca08-11eb-89fb-ecff932b9fe9.mp4
Notes:
* A newly-created record can be deleted just fine. It is properly un-rendered.
* A record that existed at page load does not seem to be immediately removed from the connection, and it renders once more with `useFragment` returning `null`.
Using `@deleteEdge` (or the corresponding `updater` code, as is in the example TODO app) works fine. However, in our use case, the record also needs to be deleted in order to update other bits of UI.
Other approaches tried:
* using both `@deleteRecord` and `@deleteEdge` together (not yet supported?)
* in `updater` function, performing explicit deleteEdge and deleting the record in different orders (same result)
Thanks for reading!
Contributor guide
Assessment
This issue has not been assessed yet.