Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export const ReactChopper = (target, componentReference) => {
if (typeof value === "object") {
value = proxify(value, [...path, key]);
}
if (!Object.prototype.hasOwnProperty.call(target, key)) {
console.warn("You are trying to set a new property \"" + key + "\" to your proxified object which was not present in the beginning. This will not work in polyfilled browsers as properties need to be sealed.");
}
target[key] = value;
componentReference.setState({ [key]: value });
return true;
Expand All @@ -21,6 +24,10 @@ export const ReactChopper = (target, componentReference) => {
}
}
let p = new Proxy(obj, makeHandler(path));
if (typeof Object.seal === "function") {
Object.seal(obj);
Object.seal(p);
}
preproxy.set(p, obj);
return p;
};
Expand Down