Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
function createReadOnlyProxy(obj: object, objName: string, location: string) {
// proxies only work on objects/arrays.
try {
if (typeof obj !== 'object' && !Array.isArray(obj)) return obj;
return new Proxy(obj, {
set() {
console.log(
`Object ${objName} is not mutable from ${location}. Check the error below for the hook/plugin that is attempting to mutate properties outside of the rules in hookInterface.ts or in other restricted areas.`,
);
return false;
},
});
} catch (e) {
return obj;
}
}
export default createReadOnlyProxy;