"TypeError: Cannot freeze" when dispatching an action with payload of type FileList #4105
Unanswered
quynhethereal
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone 👋
When I dispatch an action with payload of type FileList, ngrx would throw an error. Here is the sample code:
This issue is resolved when I clone
myFile
, like this:I'm looking to understand more about this behavior. There is a similar SO answer: https://stackoverflow.com/a/53092520 but I don't quite understand the explanation. They say that "FileList is a primitive data type so JS will treat it as read-only so it cannot be frozen" but I have tested in the JS console and JS is able to freeze this type (by calling
Object.freeze
). Moreover, I have tested dispatching actions with other primitive data types like Integer and the store works well.I have searched the docs but don't seem to find relevant discussions about FileList data type. I have just started with ngrx so I might be missing sth obvious. Hopefully sb can provide me with pointers, cheers :)
Beta Was this translation helpful? Give feedback.
All reactions