# Inject Container State Deprecation

The `injectContainerState` feature is scheduled for removal in future updates. Instead, it can now be declared in the global configuration when invoking `forRoot` or `provideStore`, or through the `@SelectorOptions` decorator. This property was introduced several years ago to facilitate the incremental migration of existing codebases.

This change specifically impacts the runtime behavior of the `@Selector` decorator and how parameters are passed into selector functions, especially when `@Selector` is used with joined selectors. It's important to note that this change does not affect the behavior of `createSelector`.

No changes need to be made when `@Selector` is called with no arguments within the state class:

```ts
export class InvoiceState {
  @Selector()
  static getInvoiceId(state: InvoiceStateModel) {
    return state.id;
  }
}
```

However, if you're calling the decorator with arguments, you would expect the container state to be injected as the first argument:

```ts
export class InvoiceLinesState {
  @Selector([InvoiceState.getInvoiceId])
  static getInvoiceLinesByInvoiceId(state: InvoiceLinesStateModel, invoiceId: number) {
    return state.invoiceLines.filter(line => line.invoiceId === invoiceId);
  }
}
```

With `injectContainerState` being removed and set to `false` by default, you now need to explicitly specify the container state in the above example:

```ts
export class InvoiceLinesState {
  @Selector()
  static getInvoiceLines(state: InvoiceLinesStateModel) {
    return state.invoiceLines;
  }

  @Selector([InvoiceLinesState.getInvoiceLines, InvoiceState.getInvoiceId])
  static getInvoiceLinesByInvoiceId(invoiceLines: InvoiceLine[], invoiceId: number) {
    return invoiceLines.filter(line => line.invoiceId === invoiceId);
  }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.ngxs.io/v19.0/deprecations/inject-container-state-deprecation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
