react-native-skia icon indicating copy to clipboard operation
react-native-skia copied to clipboard

Fix fast refresh for features backed by useLoading

Open JonnyBurger opened this issue 3 years ago • 5 comments

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

JonnyBurger avatar Jul 10 '22 11:07 JonnyBurger

CLA signed!

JonnyBurger avatar Jul 10 '22 11:07 JonnyBurger

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.

wcandillon avatar Jul 10 '22 13:07 wcandillon

@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 avatar Jul 12 '22 06:07 chrfalch

@chrfalch I lost track of what this does. Can you describe the flow and we could add tests for it.

wcandillon avatar Jul 12 '22 07:07 wcandillon

@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 avatar Jul 12 '22 07:07 chrfalch

@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?

wcandillon avatar Aug 08 '22 08:08 wcandillon

closing in favor of #811

wcandillon avatar Aug 15 '22 11:08 wcandillon