What happens if you use JSON.stringify() on a @wire value?
The data you get from
@wire
isn’t a “normal” JavaScript object. Salesforce wraps it in a Proxy so it stays reactive.-
If you do
JSON.stringify(data)
, Salesforce converts that Proxy into a plain JSON string.-
When you then
JSON.parse(...)
it back, you get a normal object (no Proxy, no reactivity).
-
-
This is useful if you just want a copy of the data to work with, but:
-
It drops any functions or hidden fields,
-
Dates become text,
-
undefined
fields disappear, -
If the object has circular references, it will throw an error.
-
Simpler analogy:
Think of the @wire
object like a live mirror that Salesforce keeps updated.
JSON.stringify
takes a snapshot photo of that mirror — you get the picture (data at that moment) but it’s no longer “live.”
Post a Comment