Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Russell alexrussell

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am alexrussell on github.
  • I am alexrussell (https://keybase.io/alexrussell) on keybase.
  • I have a public key ASDAHeM-gBzZH8uAGNY7UfaVDFtzZOW4KwN638NNVTu9oQo

To claim this, I am signing this object:

@alexrussell
alexrussell / navSaga.js
Created Nov 15, 2017
Idea of how I have implemented a `goBackTo` saga for react-navigation.
View navSaga.js
export const goBackTo = function * goBackTo ({ payload: { routeName } }) {
const { nav } = yield select()
let targetIndex
for (let i = nav.index; i > 0; i--) {
if (nav.routes[i].routeName === routeName) {
targetIndex = i + 1
break
}
@alexrussell
alexrussell / OutsideEventListener.js
Last active Oct 27, 2016
Outside event listener HOC
View OutsideEventListener.js
export default function OutsideEventListener(Target, listeners = []) {
return class OutsideEventListener extends Component {
target = null
componentDidMount() {
for (const eventName of listeners) {
window.addEventListener(eventName, this.handleEvent, false)
}
}
View gist:4195904
javascript:(function(){var els = document.querySelectorAll('p'), df, quotes=['I reckon that','My mate told me','I heard in the pub that','My mum told me','My nana always said that','According to the Daily Mail,','Common sense dictates that','Some people say','Apparently,','I read on Wikipedia that']; for (var element in els) { df = document.createElement('span'); df.innerHTML = quotes[Math.floor(Math.random() * quotes.length)] + ' '; els[element].insertBefore(df, els[element].childNodes[0]); };})();
You can’t perform that action at this time.