1

I thought they are the same, but caution in Redux tutorial states they have difference.

Full text of caution:

Redux actions and state should only contain plain JS values like objects, arrays, and primitives. Don't put class instances, functions, or other non-serializable values into Redux!

Ratbek
  • 143
  • 1
  • 7
  • does this help you: https://stackoverflow.com/questions/51742249/plain-objects-vs-class-instances-for-model-objects – Sinan Yaman Dec 11 '20 at 11:55
  • 3
    Keyword is _non-serializable_. Anything that cannot be serialized shouldn't be in the redux store. Plain javascript objects are object literals whereas instance is anything created with `new` operator – Yousaf Dec 11 '20 at 11:56
  • 1
    I *think* when they say "objects" they refer to object literals (e.g. `{ key: 'value' }`) as opposed to instances (e.g. `new MyClass()`); – secan Dec 11 '20 at 11:56
  • 2
    Actually, *non-serialisable* is the wrong keyword here. Many class instances are serialisable just fine. The actual problem is that they are *not deserialisable*, i.e. they will end up as plain objects not class instances and your code breaks when trying to call custom methods. – Bergi Dec 11 '20 at 13:51

0 Answers0