Just curious what is the difference between these examples:
(helix/defhook use-connect []
(hooks/use-effect
:once
(js/console.log "Test")))
and
(defn use-connect []
(hooks/use-effect
:once
(js/console.log "Test")))
at the moment, nothing
the goal is to add some functionality on top of defn
to provide things like:
• compile-time warning when breaking the “Rules of Hooks”
• compile-time inference of dependencies for optimizations like use-memo
and use-callback
• adding metadata about arguments so that defnc
can detect when dependencies haven’t been filled in for your custom hook
oh, and integration with react-refresh so that your custom hooks will refresh appropriately
all of these are compile time devtooling. at runtime, it will act the same as a defn
🙂 hope that helps!
Great. Thank you for detailed explanation!