> For the complete documentation index, see [llms.txt](https://www.ngxs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.ngxs.io/v18.0/deprecations/inject-container-state-deprecation.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
