Skip to content

Instantly share code, notes, and snippets.

Mark Funk mfunkie

Block or report user

Report or block mfunkie

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mfunkie
mfunkie / useCallOnUnmount.js
Last active Mar 8, 2019
Invoke a callback only on unmount of the component
View useCallOnUnmount.js
import React, { useEffect, useRef } from 'react'
// usage
function MyComponent() {
const { cleanupReduxStateWithSavedIDSoModalDoesntCloseNextTimeItIsOpened, savedID } = props
useEffect(() => {
if (savedID) {
// onSuccess could be doing something where in other areas savedID is still pulled from a redux store
onSuccess(savedID)
}
}, [savedID, onSuccess])
@mfunkie
mfunkie / slim-redux.js
Created Sep 23, 2015 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
View slim-redux.js
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@mfunkie
mfunkie / gist:65e94f42fee3962b1703
Created May 27, 2015
Relay Talk Transcription by NPM
View gist:65e94f42fee3962b1703
>> I work on products infrastructure team at
Facebook, and back in January at react day two of my
teammates Dan safer gave us introducing relay, which is
a data stream work. So today in this talk, going to
start with a description of relay for anyone who didn't
see this or who needs an infrastructure, and then I'm
going to dive into specific cards of the relay.
So let's start by thinking about how we at
Facebook were dining inclines a year ago. At that point
we had developed react, and which also buys a pattern
View gist:1efbfa3d570c83defab8
var items = [1, 2, 3, 4];
switch (true) {
case 2 === items.filter(function(item) { return item > 2; }).length:
console.log('Two items greater than two');
break;
default:
console.log('Not exactly two items greater than two');
}
@mfunkie
mfunkie / exampleUsage.html
Created Aug 15, 2014
Template Popover for Angular-UI Bootstrap
View exampleUsage.html
<div ng-app="myModule">
<script type="text/ng-template" id="myTemplatePopover.html">
<div ng-controller="PopoverTestCtrl">
<span>Is it not <b style="color:red;">glorious</b> to have <i>html</i> in a popover?</span>
<span>{{ theStuff }}</span>
<button class="btn btn-danger" ng-click="$popover.close()">Try closing here!</span>
</div>
</script>
<button class="btn btn-success" template-popover="myTemplatePopover.html" template-popover-title="I'm a title!" template-popover-placement="bottom">You can have popovers with templates too!</button>
You can’t perform that action at this time.