1.3 KiB
1.3 KiB
react
Plugin for generating type-safe Wagmi Hooks.
Import
import { react } from '@wagmi/cli/plugins'
Usage
import { defineConfig } from '@wagmi/cli'
import { react } from '@wagmi/cli/plugins'
export default defineConfig({
plugins: [
react(),
],
})
Configuration
import { type ReactConfig } from '@wagmi/cli/plugins'
abiItemHooks
- Boolean flag to generate abi item hooks (e.g. hooks for each abi function and events).
- Defaults to
true.
plugins: [
react({ abiItemHooks: false }), // [!code focus]
],
getHookName
'legacy' | ((options: { contractName: string; type: 'read' | 'simulate' | 'watch' | 'write' }) => `use${string}`)
- Function for setting custom hook names.
- Defaults to
`use${type}${contractName}`. For example,useReadErc20,useSimulateErc20,useWatchErc20Event,useWriteErc20. - When
'legacy'(deprecated), hook names are set to@wagmi/cli@1format.
import { defineConfig } from '@wagmi/cli'
import { react } from '@wagmi/cli/plugins'
export default defineConfig({
plugins: [
react({
getHookName({ contractName, type }) { // [!code focus]
return `use${contractName}__${type}` // [!code focus]
}, // [!code focus]
}),
],
})