reagent
reagent copied to clipboard
Add defc macro to create fn components with Fast Refresh support
Investigating if React Refresh support is possible in some way. It will require using a macro, because attaching necessary data to the function (component) just isn't possible when components are created when rendering Hiccup forms (what Reagent normally does.)
- Target is to get React Refresh working
- Working React Refresh will allow better dev experience on a project transitioning from Reagent to UIx/Helix
- As a side-effect this will create function components which work without
:f> - Macro to handle Hiccup or properties transform is not a target (one could probably wrap the macro with Sablono to do that)
- Seems like Refresh works for "old" components being used from
defccomponent also! No need to convert everything to use the macro?- It is possible that one old type component will force sub-tree re-mount which prevents keeping Hooks state for anything under that component?? Need to test.
- Does setting
forceResetflag cause re-mount always? If so, we might HAVE to create correct signatures to keep state for even UIx components in component tree?
TODO:
- Looks like form-2 components don't work
- Form-3 not tested, not sure if makes even sense
- Check if we could create real Hook signature now that we have macro which can analyze the code (-> keep hook state over reloads if signature doesn't change)
TODO: Controlled inputs don't work inside defc / or just dereferencing ratoms values.