@nrwl/react:hook

Create a hook

Usage

nx generate hook ...
nx g h ... # same

By default, Nx will search for hook in the default collection provisioned in angular.json.

You can specify the collection explicitly as follows:

nx g @nrwl/react:hook ...

Show what will be generated without writing to disk:

nx g hook ... --dry-run

Examples

Generate a hook in the mylib library:

nx g hook my-hook --project=mylib

Options

name (required)

Type: string

The name of the hook.

project (required)

Alias(es): p

Type: string

The name of the project.

directory

Alias(es): d

Type: string

Create the hook under this directory (can be nested).

export

Alias(es): e

Default: false

Type: boolean

When true, the hook is exported from the project index.ts (if it exists).

flat

Default: false

Type: boolean

Create hook at the source root rather than its own directory.

js

Default: false

Type: boolean

Generate JavaScript files rather than TypeScript files.

pascalCaseDirectory

Alias(es): R

Default: false

Type: boolean

Use pascal case directory name (e.g. useHook/useHook.ts).

pascalCaseFiles

Alias(es): P

Default: false

Type: boolean

Use pascal case hook file name (e.g. useHook.ts).

skipTests

Default: false

Type: boolean

When true, does not create "spec.ts" test files for the new hook.