Skip to content

Instantly share code, notes, and snippets.

View vitormalencar's full-sized avatar
🔥

Vitor Alencar vitormalencar

🔥
View GitHub Profile

Este arquivo ainda está em construção, mas espero que já possa ser de ajuda.

Introdução

Neste documento você irei falar sobre algumas coisas que eu sei e utilizo para configurar as lives. Não sou expert, nem nada, comecei a fazer oficialmente live em Outubro/Novembro em 2020, mas das coisas que sei já chegaram a ajudar algumas pessoas próximas a mim e a deixar suas lives da forma que agradavam a elas. Então, espero que possa ajudar você também.

Nota: Tudo aqui pode ser alterado de acordo com sua necessidade. Eu não estou ditando regras, nem falando uma verdade absoluta. É puramente minha singela esperiência de como uso o OBS.

Aqui você verá

@slikts
slikts / react-memo-children.md
Last active September 3, 2024 04:22
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
@ronkot
ronkot / rastas-promise.js
Last active July 25, 2023 05:42
Simple Promise implementation
const PENDING = 1;
const RESOLVED = 2;
const REJECTED = 3;
const callLater = (fn) => setTimeout(fn, 0);
class Promise {
constructor(initPromiseFn) {
this._state = PENDING;
this._value = undefined;

tracked npm

@tracked is a decorator for Preact that makes working with state values no different than properties on your component instance.

It's one 300 byte function that creates a getter/setter alias into state/setState() for a given key, with an optional initial value. The "magic" here is simply that it works as a property decorator rather than a function, so it appears to integrate directly into the language.

tracked has no dependencies and works with any component implementation that uses this.state and this.setState().

Installation

@developit
developit / .gitignore
Last active December 4, 2019 09:31
it's actually 3.9kb
.DS_Store
node_modules
dist