The Wayback Machine - http://web.archive.org/web/20201206195700/https://github.com/welldone-software/why-did-you-render/issues/74
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn on non-plain objects with same prototype and own fields #74

Open
Hypnosphi opened this issue Nov 14, 2019 · 4 comments
Open

Warn on non-plain objects with same prototype and own fields #74

Hypnosphi opened this issue Nov 14, 2019 · 4 comments

Comments

@Hypnosphi
Copy link
Contributor

@Hypnosphi Hypnosphi commented Nov 14, 2019

Right 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

@VariableVasasMT
Copy link

@VariableVasasMT VariableVasasMT commented Dec 24, 2019

Can I pick this up?

@vzaidman
Copy link
Member

@vzaidman vzaidman commented Dec 24, 2019

yes, go on :)

@vzaidman
Copy link
Member

@vzaidman vzaidman commented Apr 24, 2020

@VariableVasasMT no success? :)

@VariableVasasMT
Copy link

@VariableVasasMT VariableVasasMT commented Apr 27, 2020

@vzaidman I am extremely sorry, shit hit the fan, will pick this up, this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.