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.

Clobbering of `ref` when using TouchScrollable

See original GitHub issue

I was recently building a modal and using ScrollLock and I inadvertently introduced a bug that cost me 30 minutes or so simply by wrapping a div that had a critical ref in a ScrollLock component. It turns out that TouchScrollable clobbers the ref prop:

https://github.com/jossmac/react-scrolllock/blob/90cbf33d27b9fd0b9911cdf371c4466874ee9a10/src/TouchScrollable.js#L50-L53

There are workarounds for this (like using React.forwardRef), but at the very least this behavior should be documented.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
coreywardcommented, Jan 10, 2020

Right, but why not use applyRef internally to avoid the confusion? In any case, this ought to be documented.

2reactions
coreywardcommented, Jan 6, 2020

@wojciech-skowronek I didn’t modify the library to make it work; I just wrapped the children in an extra div like so:

 <ScrollLock>
-  <div ref={someRef}>Example</div>
+  <div><div ref={someRef}>Example</div></div>
 </ScrollLock>

This extra div will give TouchScrollable something to add its ref to without affecting someRef that I care about. This won’t work in all situations, unfortunately (depends on your DOM tree).

Read more comments on GitHub >

github_iconTop Results From Across the Web

DOM clobbering | Web Security Academy - PortSwigger
In this section, we will describe what DOM clobbering is, demonstrate how you can exploit DOM vulnerabilities using clobbering techniques, and suggest ways ......
Read more >
React Render Method Clobbering - Stack Overflow
To test this theory I wrapped this.props.onChange(value); in a setTimeout . Even with a time of 0 , the issue seems to have...
Read more >
DOM Clobbering — It's clobbering time!!! - Medium
DOM Clobbering is a technique in which we inject HTML in a page to ... Now the testObject reference is overwritten with this...
Read more >
Untitled
Jewelry made with polymer clay, Mix kiss sound 2014, Epicoccum species ... the appalachian trail, Easy refrigerator slice recipe, The quest 2 van...
Read more >
Dom Clobbering - HackTricks
... you can clobber the someObject reference with a DOM node, such as an anchor. ... to overwrite attributes of the document object...
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