Skip to content

Instantly share code, notes, and snippets.

@nathanlogan
nathanlogan / component.js
Created November 15, 2016 19:29
Emulate URL anchor page scroll functionality in a React component
import React, { Component } from 'react'
class MyTopLevelComponent extends Component {
componentDidMount () {
this.scrollToHashId()
}
componentDidUpdate () {
this.scrollToHashId()
}
@carcinocron
carcinocron / debugger pause beforeunload
Last active July 10, 2024 08:48
Chrome: pause before redirect
// Run this in the F12 javascript console in chrome
// if a redirect happens, the page will pause
// this helps because chrome's network tab's
// "preserve log" seems to technically preserve the log
// but you can't actually LOOK at it...
// also the "replay xhr" feature does not work after reload
// even if you "preserve log".
window.addEventListener("beforeunload", function() { debugger; }, false)