Skip to content

Commit

Permalink
feat: useAccountEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Aug 9, 2023
1 parent bcc6c61 commit adf54d7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ For documentation and examples, visit [wagmi.sh](https://wagmi.sh).

## Contributing

Check out the [Contributing docs][contributing] to get started.
Check out the [Contributing Guide][contributing] to get started.

## Sponsors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createWrapper, renderHook, waitFor } from '@wagmi/test/react'
import { expect, test, vi } from 'vitest'

import { WagmiProvider } from '../context.js'
import { useAccountState } from './useAccountState.js'
import { useAccountEffect } from './useAccountEffect.js'
import { useConnect } from './useConnect.js'
import { useDisconnect } from './useDisconnect.js'

Expand All @@ -13,7 +13,7 @@ test('behavior: connect and disconnect called once', async () => {
const onDisconnect = vi.fn()

const { result } = renderHook(() => ({
useAccountState: useAccountState({ onConnect, onDisconnect }),
useAccountEffect: useAccountEffect({ onConnect, onDisconnect }),
useConnect: useConnect(),
useDisconnect: useDisconnect(),
}))
Expand Down Expand Up @@ -59,7 +59,7 @@ test('behavior: connect called on reconnect', async () => {
expect(data.isReconnected).toBeTruthy()
})

renderHook(() => useAccountState({ onConnect }), {
renderHook(() => useAccountEffect({ onConnect }), {
wrapper: createWrapper(WagmiProvider, { value: config }),
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Evaluate } from '@wagmi/core/internal'
import { useConfig } from './useConfig.js'
import { useEffect } from 'react'

export type UseAccountStateParameters = {
export type UseAccountEffectParameters = {
onConnect?(
data: Evaluate<
Pick<
Expand All @@ -18,8 +18,8 @@ export type UseAccountStateParameters = {
onDisconnect?(): void
}

/** https://wagmi.sh/react/hooks/useAccountState */
export function useAccountState(parameters: UseAccountStateParameters = {}) {
/** https://wagmi.sh/react/hooks/useAccountEffect */
export function useAccountEffect(parameters: UseAccountEffectParameters = {}) {
const { onConnect, onDisconnect } = parameters
const config = useConfig()

Expand Down
6 changes: 3 additions & 3 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export { WagmiProviderNotFoundError } from './errors/context.js'
export { type UseAccountReturnType, useAccount } from './hooks/useAccount.js'

export {
type UseAccountStateParameters,
useAccountState,
} from './hooks/useAccountState.js'
type UseAccountEffectParameters,
useAccountEffect,
} from './hooks/useAccountEffect.js'

export {
type UseBalanceParameters,
Expand Down
4 changes: 2 additions & 2 deletions playgrounds/vite-react/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
useAccount,
useAccountState,
useAccountEffect,
useBalance,
useBlockNumber,
useChainId,
Expand All @@ -16,7 +16,7 @@ import {
import { optimism } from 'wagmi/chains'

function App() {
useAccountState({
useAccountEffect({
onConnect(data) {
console.log('onConnect', data)
},
Expand Down

1 comment on commit adf54d7

@vercel
Copy link

@vercel vercel bot commented on adf54d7 Aug 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

wagmi-v2 – ./docs

wagmi-v2-wagmi-dev.vercel.app
wagmi-v2.vercel.app
wagmi-v2-git-alpha-wagmi-dev.vercel.app
alpha.wagmi.sh

Please sign in to comment.