Warn on non-plain objects with same prototype and own fields
See original GitHub issueRight now there is a false negative with non-plain objects passed as props, e.g. errors:
const DisplayError = memo(({error}) => (
<>
<h1>{error.message}</h1>
<p>{error.stack}<p>
{error instanceof SomeSpecificError && <SomethingElse />}
</>
)
const App = () => {
const [counter, increment] = useReducer(state => state + 1, 0)
useEffect(() => setTimeout(increment, 100), [])
return <DisplayError error={new Error('message')} />
}
here, error
prop is deep equal to the previous value but there’s no warning
One possible solution is to check both Object.getPrototypeOf(obj)
and Object.keys(obj)
for non-plain objects
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Inheritance and the prototype chain - JavaScript | MDN
Each object has a private property which holds a link to another object called its prototype. That prototype object has a prototype of...
Read more >Prototypal inheritance - The Modern JavaScript Tutorial
In JavaScript, objects have a special hidden property [[Prototype]] (as named in the specification), that is either null or references another ...
Read more >Understanding Prototypes and Inheritance in JavaScript
In this tutorial, we will learn what object prototypes are and how to use the constructor function to extend prototypes into new objects....
Read more >Use of 'prototype' vs. 'this' in JavaScript? - Stack Overflow
In JavaScript, all functions objects have a prototype property by default so there is no separate code to create an A.prototype object. In...
Read more >Prototype in JavaScript - TutorialsTeacher
The prototype is an object that is associated with every functions and objects by default in JavaScript, where function's prototype property is accessible ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Great! I’ll go over the pr asap! Thank you!
@vzaidman @VariableVasasMT I saw this issue was stale for few months so I opened a PR for it, hope you don’t mind. LMKWYT 😃