Fix fast refresh for features backed by useLoading
Not tested with anything except with useFont() on my own project.
Need your assessment whether this is a good idea.
Bug flow:
- Call
useFont()with any font - Loader gets executed because font has changed from undefined -> font
- Component gets fast refreshed
- Effect triggers again, but since
prevSourceRef.current === source, it gets set to null even though font is still there
Bugfix is to only set it to null if there is no source anymore
Fixes #677
CLA signed!
I'm able to reproduce the issue on RN I assume this might be a RN web issue only? Or it might be related to require returning something different on web .
@chrfalch should remove this pattern altogether? I lost track of what kind of input source could have a different identity but shouldn't trigger a new resource load. Or should we just remove the conditional branch that does setData(null)?
We can also add tests for this.
@chrfalch should remove this pattern altogether? I lost track of what kind of input source could have a different identity but shouldn't trigger a new resource load. Or should we just remove the conditional branch that does
setData(null)?
Not sure if we should remove the pattern, without it we won't be able to load resources correctly?
We can also add tests for this.
Yes - absolutely.
@chrfalch I lost track of what this does. Can you describe the flow and we could add tests for it.
@chrfalch I lost track of what this does. Can you describe the flow and we could add tests for it.
Same here :) Will look at it when I'm back :)
@chrfalch I would love to add tests for the prevSourceRef logic, but I'm struggling to make sense of it. Please send me some flow descriptions which I could transcribe as tests, or maybe we should remove them?
closing in favor of #811