wagmi icon indicating copy to clipboard operation
wagmi copied to clipboard

Solid.js Support

Open glitch-txs opened this issue 1 year ago • 3 comments

Solid.js Support

This PR integrates a new package for Solid first class support.

This covers the core "hooks"

  • [x] useAccount -> createAccount
  • [x] useAccountEffect -> createAccountEffect
  • [x] useChainId -> createChainId
  • [ ] useClient (type issue)
  • [x] useConfig -> createConfig
  • [x] useConnect -> createConnect
  • [x] useConnections -> createConnections
  • [ ] useConnectorClient -> createConnectorClient (error when being called)
  • [x] useConnectors -> createConnectors
  • [x] useDisconnect -> createDisconnect
  • [x] useSwitchAccount -> createSwitchAccount
  • [x] useSwitchChain -> createSwitchChain

Philosophy

Considerations:

  • Tanstack query follows the same naming convention from Solid, which uses the prefix "create" for functions returning reactive values
  • Tanstack functions return a Solid store, these stores cannot be destructured otherwise they lose reactivity.
  1. To avoid confusion we are using "stores" (built on top of signals) instead of "signals", since the values are accessed differently (signals are functions). Since stores cannot be desctructured and for some "hooks" we are returning values from Query and from Wagmi at the same time, the return type is going to be an object containing these stores.

Example:

function Account(){
  const { account } = createAccount()

  return <div>{account.address}</div>
}
  1. To follow the framework convention (adopted by Tanstack as well) we are using the prefix "create" instead of "use". This introduces a naming confict with useConfing and the core function createConfig, for a quick workaround the core function is being renamed to initConfig. (we can discuss this)

  • [ ] Package (on process)
  • [ ] Docs
  • [ ] vite-solid playground (80%)
  • [ ] ssr-solid playground
  • [ ] tests

NOTE: This is currently under solid-no-bun folder but will later be moved to the right place.

glitch-txs avatar Feb 04 '24 19:02 glitch-txs

⚠️ No Changeset found

Latest commit: 312e9d5a678597a0002552324964ed65776cd70c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Feb 04 '24 19:02 changeset-bot[bot]

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
wagmi ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 5, 2024 2:17am

vercel[bot] avatar Feb 04 '24 19:02 vercel[bot]

will refactor

glitch-txs avatar Apr 03 '24 19:04 glitch-txs