Skip to content

Instantly share code, notes, and snippets.

View ahmad-reza619's full-sized avatar
🚀
probably working

Ahmad Reza ahmad-reza619

🚀
probably working
View GitHub Profile
@slikts
slikts / react-memo-children.md
Last active June 16, 2024 14:24
Why using the `children` prop makes `React.memo()` not work

nelabs.dev

Why using the children prop makes React.memo() not work

I've recently ran into a pitfall of [React.memo()][memo] that seems generally overlooked; skimming over the top results in Google just finds it mentioned in passing in a [React issue][regit], but not in the [FAQ] or API [overview][react-api], and not in the articles that set out to explain React.memo() (at least the ones I looked at). The issue is specifically that nesting children defeats memoization, unless the children are just plain text. To give a simplified code example:

const Memoized = React.memo(({ children }) => (<div>{children}</div>));
// Won't ever re-render
<Memoized>bar</Memoized>
// Will re-render every time; the memoization does nothing
@xezno
xezno / uwuify.js
Created February 12, 2019 13:12
The UwU Button
function getUwuString(a){return a.replace(/[.]/g,"!!!").replace(/th|Th/g,"f").replace(/W/g,"w-w").replace(/l|L|r|R/g,"w").toLowerCase()}function uwuify(a){var b=["^~^","UwU","OwO","O_O","O_o","oWo","OvO","UvU","*~*",":3","=3","<(^V^<)"];if(null==a)var a=document.body;a.childNodes.forEach(function(a){if(!(3===a.nodeType))uwuify(a);else if(""!==a.nodeValue.trim()){var c=a.nodeValue;c=getUwuString(c),0==Math.floor(2*Math.random())&&(c+=" "+b[Math.floor(Math.random()*b.length)]),a.nodeValue=c}})}uwuify();
@jsoendermann
jsoendermann / result.ts
Last active January 6, 2021 15:44
TypeScript Result type
interface IValue<T> {
type: 'value'
value: T
}
interface IError<E extends Error> {
type: 'error'
error: E
}
@jfmengels
jfmengels / lodash-fp-documentation.md
Last active February 6, 2024 20:57
Generated docs for Lodash/fp. Help make them better at https://github.com/jfmengels/lodash-fp-docs
Ruby Quickstart for Refugees:
--
# is a comment.
You don't need semicolons.
Ruby aims to be elegant and readable, so punctuation and boilerplate are
minimal.
--