This file contains hidden or 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
echo "Setup WSL's Git to use the same credential manager that the Windows git.exe is using" | |
GIT_CREDENTIAL_MANAGER_CORE_EXE=$(wslpath "$(git.exe config --global --get credential.helper | sed 's/\\\(\s\)/\1/g')" | sed 's/\(\s\)/\\\1/g') | |
git config --global credential.helper "$GIT_CREDENTIAL_MANAGER_CORE_EXE" |
This file contains hidden or 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
MyContext.slice(value => value.foo); | |
const KeyContext = useMemo(() => MyContext.slice(value => value[key]), [key]) | |
const keyValue = useContext(KeyContext); | |
const KeyContext = useMemo(() => MyContext.slice(value => value[key]), [key]) | |
return <KeyContext.Consumer>{keyValue => keyValue}</KeyContext.Consumer> |
This file contains hidden or 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 warning from 'warning'; | |
import { useState } from 'react'; | |
let idCounter = 0; | |
function nextId() { | |
idCounter += 1; | |
warning( | |
idCounter < 1e10, | |
'Id: you might have a memory leak.' + | |
'The idCounter is not supposed to grow that much.' |
This file contains hidden or 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 warning from 'warning'; | |
import { Component } from 'react'; | |
let idCounter = 0; | |
function nextId() { | |
idCounter += 1; | |
warning( | |
idCounter < 1e10, | |
'Id: you might have a memory leak.' + | |
'The idCounter is not supposed to grow that much.' |
This file contains hidden or 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
Show hidden characters
{ | |
"presets": [ | |
[ | |
"@babel/preset-env", | |
{ | |
"targets": { | |
"node": 8 | |
} | |
} | |
] |
This file contains hidden or 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
{ | |
"presets": [ | |
[ | |
"@babel/preset-env", | |
{ | |
"modules": "commonjs" | |
} | |
] | |
] | |
} |
This file contains hidden or 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
@memoize | |
export default function myExpensiveFunction(data) { | |
// do something expensive | |
return result; | |
} |
This file contains hidden or 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 {PureComponent} from 'react'; | |
export default class AnchorRef extends PureComponent { | |
state = { | |
ref: undefined, | |
}; | |
_setRef = ref => { | |
this.setState({ref}); | |
}; |
This file contains hidden or 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
module.exports = function (file, api, options) { | |
const j = api.jscodeshift; // alias the jscodeshift API | |
const root = j(file.source); // parse JS code into an AST | |
let mutation = false; | |
const isJSXIdentifier = (node, name) => j.JSXIdentifier.check(node) && node.name === name; | |
// Remove the opening and closing element names if they are Fragment or React.Fragment | |
const update = node => { |
This file contains hidden or 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
<span class=""><span class="pl-k" style="box-sizing:border-box;color:#d73a49;" >export</span> <span class="pl-k" style="box-sizing:border-box;color:#d73a49;" >const</span> <span class="pl-c1" style="box-sizing:border-box;color:#005cc5;" >styles</span> <span class="pl-k" style="box-sizing:border-box;color:#d73a49;" >=</span> <span class="pl-smi" style="box-sizing:border-box;color:#24292e;" >theme</span> <span class="pl-k" style="box-sizing:border-box;color:#d73a49;" >=></span> ({</span><br> | |
<span class=""> root<span class="pl-k" style="box-sizing:border-box;color:#d73a49;" >:</span> {</span><br> | |
<span class="yes" style="background-color:#81A594;" > display<span class="pl-k" style="box-sizing:border-box;color:#d73a49;" >:</span> <span class="pl-s" style="box-sizing:border-box;color:#032f62;" ><span class="pl-pds" style="box-sizing:border-box;color:#032f62;" >'</span>flex<span class="pl-pds" style="box-sizing:border-box;color:#032f62;" >'</span></span>,</span><br> | |
<span class="yes" style |