This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect } from 'react'; | |
import { useRevalidator, useSearchParams } from 'react-router-dom'; | |
export function useRevalidateInterval( | |
shouldRevalidate: boolean, | |
revalidateSearchParam: string, | |
intervalTimeoutMs = 3000 | |
) { | |
const [searchParams, setSearchParams] = useSearchParams(); | |
const revalidator = useRevalidator(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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])) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |