diff --git a/src/index.js b/src/index.js index dbb9054..325c2a1 100644 --- a/src/index.js +++ b/src/index.js @@ -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; @@ -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; };