pmndrs / swc-jotai

MIT License
90 stars 14 forks source link

atom factory atoms getting confused with refresh plugin enabled #4

Closed jvatic closed 1 year ago

jvatic commented 1 year ago

When the @swc-jotai/react-refresh plugin is enabled, atoms created using a factory function have their values confused (i.e. given two atoms with different initial values, both of them will have the same value). Disabling the plugin returns the atoms to the correct behavior.

See https://github.com/jvatic/pmndrs-swc-jotai-issue-4 for a minimal repro.

Thisen commented 1 year ago

Thanks for the report @jvatic. What is the expected outcome in this case? No refresh support for these scenarios? I don't think we can capture these factory scenarios.

jvatic commented 1 year ago

@Thisen Yeah, no refresh support for these scenarios sounds reasonable. For my use case there are still a number of atoms using the regular flow where having refresh would be useful. (Ideally factory scenarios could be supported too, but I totally get that being out of scope.)

Thisen commented 1 year ago

Should be fixed with @swc-jotai/react-refresh@0.0.4.