in general when writing hook function, I took the habit of doing it like that:
[<Hook>]
let useAuth () =
React.useContext(AuthContext)
because I was thinking that the [<Hook>] attributes was just "ensur[ing] the generated code starts with "use" in order for fast-refresh to pick it up" (quoted from the doc comment).
But it is not really "ensuring" but always forcing it to start with use even if the name already start with use.
So for example, the example I provided generates useuseAuth which looks really ugly hide a few characters to the generated JS.
If you think that the current behaviour is ok, does Hook attribute do something else beside a adding use in the beginning?
If not, is it safe to assume that removing it in case would be safe?
I took the habit of writing it with the [<Hook>] because it make easy to know that this is hook. Kind of like it is easy that all functions starting with [<ReactComponent>] are react components.
Hello,
in general when writing hook function, I took the habit of doing it like that:
because I was thinking that the
[<Hook>]
attributes was just "ensur[ing] the generated code starts with "use" in order for fast-refresh to pick it up" (quoted from the doc comment).https://github.com/Zaid-Ajaj/Feliz/blob/4d621ebabfabef1723144ff155121397ce701e13/Feliz.CompilerPlugins/Hook.fs#L6-L7
But it is not really "ensuring" but always forcing it to start with
use
even if the name already start withuse
. So for example, the example I provided generatesuseuseAuth
which looks really ugly hide a few characters to the generated JS.If you think that the current behaviour is ok, does Hook attribute do something else beside a adding
use
in the beginning? If not, is it safe to assume that removing it in case would be safe?I took the habit of writing it with the
[<Hook>]
because it make easy to know that this is hook. Kind of like it is easy that all functions starting with[<ReactComponent>]
are react components.