Replies: 1 comment
-
Nice spot! This is something we are working on addressing in v2. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Some things I observed when I stumbled upon #2665:
config
which is passed intoWagmiConfig
is not used much. Most of the hooks just call@wagmi/core
.@wagmi/core
outside of the React tree, and even call with noconfig
variable, is becausecreateConfig
(both the React version and the core version) has the side effect of setting a global variable. This global variable is the source of truth. This side-effect is non-obvious since given the namecreateConfig
and it's not documented.While it's nice that we can do 2., it comes at the cost of the pitfalls of global variables (#2665) and not being the React way. Why not either go all the way and have no Provider, or go all the way and use
useConfig()
everywhere as the source of truth (the idiomatic React way / developer expectation)?One way to incrementally adopt
useConfig()
could be to add an optionalwagmiConfig
parameter to the@wagmi/core
functions so that lines likeconst config = getConfig()
becomeconst config = wagmiConfig ?? getConfig()
. Then the hooks can call like:^this would be mostly backwards-compatible, though technically still breaking, because JavaScript lets you pass in extra junk parameters and some users could be doing that
One could then go further and make a more breaking change like:
@wagmi/core
'screateConfig
tosetConfig
and document the side effectwagmi
(React)'screateConfig
ascreateConfig
but remove the side effect (React users can then no longer call vanilla@wagmi/core
without passing inconfig
)Thoughts? Open to the idea? Open to contributions?
Beta Was this translation helpful? Give feedback.
All reactions