@nx/react:redux

Create a Redux state slice for a React project.

Usage

1nx generate redux ... 2
1nx g slice ... #same 2

By default, Nx will search for redux in the default collection provisioned in workspace.json.

You can specify the collection explicitly as follows:

1nx g @nx/react:redux ... 2

Show what will be generated without writing to disk:

1nx g redux ... --dry-run 2

Examples

Generate a Redux state slice with the exported symbol matching the file name. It results in the slice fooSlice at mylib/src/lib/foo.slice.ts:

1nx g @nx/react:redux mylib/src/lib/foo.slice.ts 2

Generate a Redux state slice with the exported symbol different from the file name. It results in the slice customSlice at mylib/src/lib/foo.slice.ts:

1nx g @nx/react:redux mylib/src/lib/foo.slice.ts --name=custom 2

Generate a Redux state slice without providing the "slice" suffix and the file extension. It results in the slice fooSlice at mylib/src/lib/foo.slice.ts:

1nx g @nx/react:redux mylib/src/lib/foo 2

Options

path

Required
string

The file path to the Redux state slice. Relative to the current working directory.

appProject

a
string

The application project to add the slice to.

name

string

The Redux state slice symbol name. Defaults to the last segment of the file path.

js

Deprecated
boolean

Generate JavaScript files rather than TypeScript files.

Provide the full file path including the file extension in the path option. This option will be removed in Nx v21.