NgRx Ducks
  • Introduction
  • @ngrx-ducks/core
    • Installation
    • Architecture
      • @StoreChunk
      • createDuck
      • getReducer
      • createMutableDuck
      • getMutableReducer
      • useSelect
      • useSelectors
      • useActions
    • Guides
      • Quick Start
  • Migrations
    • v15
  • Resources
  • FAQ
  • GitHub
  • Changelog
  • Sponsor
Powered by GitBook
On this page

Was this helpful?

  1. Migrations

v15

PreviousMigrationsNextResources

Last updated 2 years ago

Was this helpful?

useActions

Due to an open issue in TypeScript, Decorators behave differently in ES2022 (). That's why it is not possible to use inside a StoreChunk initizilizing a static field of that class.

Currently, we do not know if the issue is a bug or a planned breaking changed. Once there is an update, we will update the documentation accordingly.

import {
  useActions,
  StoreChunk
} from '@ngrx-ducks/core';

@StoreChunk()
export class Chunk {
  static actions = useActions(Chunk); // ❌ Will throw a runtime error, because Chunk is undefined at this point.
}

This means inlining useActions is not possible at the moment.

To resolve this issue, you need to move useActions outside your Chunk.

mport {
  useActions,
  StoreChunk
} from '@ngrx-ducks/core';

@StoreChunk()
export class Chunk { }

export const chunkActions = useActions(Chunk); // ✅

https://github.com/microsoft/TypeScript/issues/51570
useActions