question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ripple computeBoundingRect should escape out if return null or undefined

See original GitHub issue

https://github.com/material-components/material-components-web/blob/c8d9117e2c3f7a538cf1fa65ae67f22399c8d05d/packages/mdc-ripple/foundation.js#L545

This is a React specific issue. We can never guarantee that we’ll actually have a DOM element since we might be in process of tearing a component down.

This leads us to an adapter implementation like this which isn’t ideal

computeBoundingRect: () =>
        this.root.ref ? this.root.ref.getBoundingClientRect() : {width: 0, height: 0},

Should be an easy enough fix, just a check in the foundation that computeBoundingRect returns a truthy value, which would lead to an implementation like this, and do nothing if we don’t have a dom node

computeBoundingRect: () =>
        this.root.ref && this.root.ref.getBoundingClientRect()

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
jamesmfriedmancommented, Apr 3, 2019

Cool, I’ll just keep returning the fake object as a workaround.

0reactions
moog16commented, Apr 3, 2019

@jamesmfriedman we have been talking about this, and although it would clean up React code (for RMWC and MDC React), it would mean we would need to have the null check in many places. We think that it should be the responsibility of the framework instead.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it better to return `undefined` or `null` from a javascript ...
In that case, I would recommend returning a null. Note that a function with no specified return value implicitly returns undefined. From the...
Read more >
Null Vs Undefined - Web Dev Simplified Blog
Both null and undefined mean that there is no value. If a variable is set to null or undefined it has no value...
Read more >
webnfc-shoppingcart-demo/main-app.js.map at master - GitHub
n // In particular, Edge/IE can return them out of order, so we cannot\n // assume a correspondence between part index and attribute...
Read more >
Essential JavaScript: Mastering null vs undefined
Both null and undefined are special non-value values to represent nothingness. By the end of this article, you will understand what we mean ......
Read more >
Check if a Value Is Null or Undefined in JavaScript or Node.js
This tutorial shows you how to check whether a given value is either null or undefined .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found