You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should be able to signal that an expression should be wrapped in a use-memo or use-callback by annotating it with metadata in the body of a defnc or a defhook.
(defncmy-component
[{:keys [value]}]
^:memo (d/div value)) ;; returns the same react element for the save `value`
^:memo and ^:callback metadata should tell defnc and defhook to emit a use-memo or use-callback hook that will automatically fill dependencies using the same algorithm as :auto-deps.
A dependency seq can also be provided to override this behavior:
(defncmy-component
[{:keys [foo bar baz]}]
^{:memo [foo]} (d/div value)) ;; ignores changes to `bar` and `baz`
^:memo and ^:callback metadata should be usable in let bindings:
Is there something missing in the latest version of Helix? I know that defnc exposes ^:memo and ^:callback as metadata optimizations. I'm not sure about defhook.
Right now, defnc implements this behind a feature flag you may enable. defhook does not yet support it.
I haven't fully tested it yet in production, which is why it's still behind a feature flag. In general I'm still a little unsure about using metadata to manage these type of semantics. I also want to ensure that it will emit compile warnings when breaking the rules of hooks.
We should be able to signal that an expression should be wrapped in a
use-memo
oruse-callback
by annotating it with metadata in the body of adefnc
or adefhook
.^:memo
and^:callback
metadata should telldefnc
anddefhook
to emit ause-memo
oruse-callback
hook that will automatically fill dependencies using the same algorithm as:auto-deps
.A dependency seq can also be provided to override this behavior:
^:memo
and^:callback
metadata should be usable inlet
bindings:^:memo
and^:callback
should allow enforcement of the Rules of Hooks checks that are currently behind an experimental feature flag.The text was updated successfully, but these errors were encountered: