Sphere
Log in Join
☆ 8

Hot reload lost all my component state after an upgrade

After upgrading React Native, fast refresh resets state in screens that used to keep it. I use hooks and export the component as default.

⚑ Report

3 replies

☆ 0
S stackfan ·2d ago#1

Fast refresh preserves state only for components that export a single function and do not change hooks between edits. Check for HOC wrappers.

⚑ Report
☆ 0
E Erna ·2d ago#2

I wrapped the screen in a context provider inside the same file.

⚑ Report
☆ 0
P Paul ·2d ago#3

Move the provider to a parent file. When the exported component changes shape, fast refresh deliberately remounts it.

⚑ Report
Log in to reply.