Skip to content

react

Plugin for generating type-safe Khizab Hooks.

Import

ts
import { react } from '@khizab/cli/plugins'
import { react } from '@khizab/cli/plugins'

Usage

ts
import { defineConfig } from '@khizab/cli'
import { react } from '@khizab/cli/plugins'

export default defineConfig({
  plugins: [
    react(),
  ],
})
import { defineConfig } from '@khizab/cli'
import { react } from '@khizab/cli/plugins'

export default defineConfig({
  plugins: [
    react(),
  ],
})

Configuration

ts
import { type ReactConfig } from '@khizab/cli/plugins'
import { type ReactConfig } from '@khizab/cli/plugins'

getHookName

((options: { contractName: string; type: 'read' | 'write' }) => `use${string}`)

  • Function for setting custom hook names.
  • Defaults to `use${type}${contractName}`. For example, useReadCoin, useWriteCoin.
ts
import { defineConfig } from '@khizab/cli'
import { react } from '@khizab/cli/plugins'

export default defineConfig({
  plugins: [
    react({
      getHookName({ contractName, type }) { 
        return `use${contractName}__${type}` 
      }, 
    }),
  ],
})
import { defineConfig } from '@khizab/cli'
import { react } from '@khizab/cli/plugins'

export default defineConfig({
  plugins: [
    react({
      getHookName({ contractName, type }) { 
        return `use${contractName}__${type}` 
      }, 
    }),
  ],
})

Released under the MIT License.