NGXS TypeError: Freezing not possible in Angular

https://i.sstatic.net/uD6Vp.png

The block of code responsible for triggering the specified action

  constructor(auth: AuthService, private store: Store) {
    this.userAuth = auth.signedIn.subscribe({ next: (user) => {
      this.user = user;
      this.store.dispatch(new SetUser(user));
    }});
  }

The definition of the actions being carried out

import firebase from 'firebase/app';

export class SetUser {
  static readonly type = '[firebase.User | null] Add';

  constructor(public payload: firebase.User | null) {}
}

Here's how my store is implemented:

    @Action(SetUser)
    add({ patchState }: StateContext<UserStateModel>, { payload }: SetUser): void {
        patchState({
            user: payload
        });
    }
@State<UserStateModel>({
    name: 'user',
    defaults: {
        user: null
    }
})

Answer №1

To update the code, change

static readonly type = '[firebase.User | null] Add';
to simply:

static type = '[firebase.User | null] Add';

Without being able to view the entirety of your code, it's difficult to pinpoint the exact issue you are facing. However, based on the error message regarding a readonly property, my best assumption is that there may be some readonly properties within firebase.User.

It's possible that NGXS is attempting to freeze an object in the store, which involves overwriting and is not allowed for readonly properties. If the previous suggestions do not resolve the issue, I recommend investigating any potential readonly properties within the firebase.User object.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The cachedResponse does not contain any header information

I'm currently working on figuring out the age of a cached response by utilizing the date header of the response. I attempted to do this using a plugin that utilizes cachedResponseWillBeUsed. However, when trying to access cachedResponse.headers, I am ...

What other configurations are necessary to switch the default port of Angular from 4200 to a different number?

Currently, I am diving into the world of asp.net core webapi and angular 13 through Visual Studio Community 2022. The project setup involves two distinct projects built from these templates: Standalone TypeScript Angular Project Asp.Net Core Web API In ...

Utilizing JQuery's $(document).ready() function following a window.location change

I'm having trouble getting a JavaScript function to run after being redirected to a specific page like "example.com" when the DOM is ready for it to work with. Unfortunately, it seems that $(document).ready() is running before "example.com" finishes l ...

What is the process for updating the state value in Ngrx version 9.x?

I'm currently exploring how to assign a specific value in the most recent release of Ngrx. The documentation explains how to increase/decrease/reset values in the store, however, there are no examples provided on setting values dynamically or passing ...

Running into difficulties while attempting to sort through an object utilizing an array

My task is to filter a collection of objects based on an array of Fids. I have an object, $target = $('#tableA tr[data-id="' + elm.id + '"]'); // Collection of tr And I also have an array, var fids = $("#tableB tr .New.selected").pa ...

Issue with mouseover in the jQuery area

As I navigate through a WordPress website, I am attempting to create a mandala using dynamic images. Utilizing jQuery and CSS areas, I aim to display the corresponding image when hovering over a specific section. However, I am facing an issue where there ...

Querying escape characters from JSON to JavaScript

When trying to stringify quotes (' and "), it is necessary to escape them. However, the following results in Firebug can be puzzling: 1. >> JSON.stringify({foo: "a"a'a'}); SyntaxError: missing } after property list Interpretation: Th ...

What coding techniques can be used to create dynamic animation of a log stream in javascript/css

When I have a series of events in my browser, I want to display them as a list with a smooth animation effect. As each new event comes in, I'd like the existing items to slide down gracefully, making room for the new event to fade in at the top of the ...

Is the see-through sticky header going to overlay the main banner?

I recently completed developing a client's website using Squarespace. Now, I am looking to design a header that: 1) Initially has a transparent background upon the user's arrival on the page 2) Transitions to a solid background color and sticks ...

Regular expressions should be of a specific length and include both letters and numbers

I am trying to create a regular expression that can identify substrings of length 10-15 containing only [A-Z0-9], with at least one letter and one number (spaces are permissible but not other special characters). Here are some examples: ABABABABAB12345 sh ...

What is the best way to extract information from a table using Javascript?

Here is an example of the HTML code I am working with: <table id="TableAddresses"> <tbody> <tr> <td> string 1 </td> <t ...

Steps for embedding the code into your website

I'm facing an issue with integrating a .jsx file into my website. I tried testing it on a single-page demo site, but nothing is showing up. Can someone guide me through the steps to successfully integrate it onto my site? I've also attached the . ...

Using an asynchronous for loop to assign a background image to a div element

I am facing an issue with setting the background image of an observable array in my Ionic application. Here is the code snippet I am using: <ion-card *ngFor="let picture of pictures$ | async;" <div class="user-image" [ngStyle]="{'background- ...

Why won't the JavaScript work when linking to a carousel slide from another page?

Trying to follow this 6-year-old guide, but my JavaScript isn't triggering when the URL contains #slide_ - have things changed? Linking to a specific Bootstrap carousel slide from another page My code on page 2: <!doctype html> <html> &l ...

Tips for discovering the exact positions of child divs that are Nth siblings within a parent div

I have designed a new calendar interface with dynamic functionality. When the user clicks on any time slot displayed in IMAGE1, a span element is created dynamically to represent 8 hours starting from that clicked time. My question is, how can I access th ...

Is it necessary to save the details of a specific position in local storage when sliding?

Currently, I am in the process of replicating a webpage design from . I have written the code for the functionality where images and phrases change on every slide. There are three different phrases and images that are being displayed, and my goal is to sto ...

Dynamically loading iframes with JQuery

I have implemented a jQuery script to load another URL after a successful AJAX request. $(document).ready(function() { var $loaded = $("#siteloader").data('loaded'); if($loaded == false){ $("#siteloader").load(function (){ ...

Issues with jQuery Ajax functionality in Rails application not achieving successful completion

When a card is moved onto another stack, an Ajax call is triggered twice. This only happens when there are multiple stacks. However, if the cards are rearranged within the same stack, the call is triggered only once. The Ajax call sends an array of IDs fo ...

What is the best way to reset input autocomplete styles?

I am working with a basic Bootstrap form that is submitted using JavaScript. Upon clicking the submit button, the data is processed and the input values are reset without the need to reload the page: if( json.success ) { $('#form_sendemail').f ...

There are two references to an object, but even if one of them is modified, the second reference continues to show the

During my attempts to troubleshoot an issue in a JS plugin, I noticed that one variable was sometimes affecting another and sometimes not. In order to investigate further, I added the following code: var a = $('#w3').data('fileinput'). ...