Skip to content

Instantly share code, notes, and snippets.

Avatar
🚲

Vlad Derzhavin avevlad

🚲
View GitHub Profile
@slikts
slikts / react-memo-children.md
Last active Sep 20, 2021
Why using the `children` prop makes `React.memo()` not work
View react-memo-children.md

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
View useReducerWithEmitEffect.js
const {useCallback, useEffect, useReducer, useRef} = require('react');
let effectCapture = null;
exports.useReducerWithEmitEffect = function(reducer, initialArg, init) {
let updateCounter = useRef(0);
let wrappedReducer = useCallback(function(oldWrappedState, action) {
effectCapture = [];
try {
let newState = reducer(oldWrappedState.state, action.action);
@artyomtrityak
artyomtrityak / react-hooks-typescript.tsx
Last active Feb 7, 2019
React Hooks custom hook use typescript
View react-hooks-typescript.tsx
enum DROPDOWNS {
REPORT = "REPORT",
USER = "USER"
}
type IDropdowns = keyof typeof DROPDOWNS | null;
type IUseDropdown = [
RefObject<HTMLInputElement>,
IDropdowns,
@artyomtrityak
artyomtrityak / dropdown-hooks.tsx
Last active Feb 7, 2019
React hooks window addEventListener local variables
View dropdown-hooks.tsx
import React, { useState, useRef, useEffect, RefObject } from "react";
enum DROPDOWNS {
REPORT = "REPORT",
USER = "USER"
}
type IDropdowns = keyof typeof DROPDOWNS | null;
type IUseDropdown = [
@james-jhang
james-jhang / ffmpeg_screen_vidoe.md
Last active Apr 27, 2021
Record screen by ffmpeg.
View ffmpeg_screen_vidoe.md

Record Chrome screen by ffmpeg.

Commands

The command below can record screen video by ffmpeg on Windows.

ffmpeg -y -rtbufsize 100M -f gdigrab -framerate 30 -probesize 10M -draw_mouse 1 -i title="Task Manager" -c:v libx264 -r 30 -preset ultrafast -tune zerolatency -crf 25 -pix_fmt yuv420p "video output.mp4"
View Ситуация с курсом по UX на Хекслете и курсом Антона Жиянова.md

Привет,

В начале 2018 года Максим Шайхалов (https://twitter.com/p1xe1) предложил разработать и разместить на Хекслете несколько курсов по дизайну, пользовательскому опыту и интерфейсам. Первым в списке был курс «Введение в проектирование интерфейсов». После обсуждения планов и содержания курсов, в апреле Максим подготовил первые несколько уроков первого курса, а я прочитал и опубликовал их по адресу https://ru.hexlet.io/courses/intro-to-ux

Спустя несколько недель Антон Жиянов (https://twitter.com/nalgeon/) написал в Твиттере https://twitter.com/nalgeon/status/984039364111093760 о том, что уроки в курсе Максима повторяют email-курс «Дизайн интерфейсов для нормальных людей» (https://dangry.ru/jan/), созданный Антоном Жияновым и Ольгой Коноваловой. Максим ответил https://twitter.com/p1xe1/status/984100766674808834 Антону, а также описал ситуацию и свою позицию мне в личной переписке.

Примеры Антона (https://twitter.com/nalgeon/status/984111609084825601) явно показывают его правоту. Сомнений нет: тексты Максим

@berkedel
berkedel / flow-error-icu4c-not-loaded.md
Created Apr 4, 2018
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.60.dylib
View flow-error-icu4c-not-loaded.md

How to solve dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.60.dylib

brew uninstall --ignore-dependencies node icu4c
brew install node
View 1-future-ideas.js
const React = require("react");
const Lifecycles = React.createLifecycleEvents({
didMount({ setState }) {
setState({
disabled: false,
});
},
didUpdate({ inputRef }) {
if (document.activeElement !== inputRef.value) {
View ProfilingPlugin.js
const chalk = require("chalk");
const { performance } = require("perf_hooks");
class ProfilingPlugin {
apply(compiler) {
// Compiler Hooks
Object.keys(compiler.hooks).forEach(hookName => {
compiler.hooks[hookName].intercept(makeInterceptorFor("Compiler")(hookName))
});
Object.keys(compiler.resolverFactory.hooks).forEach(hookName => {
@prog
prog / .gitlab-ci.yml
Created Dec 14, 2017
How to use composer (php) including cache with gitlab-ci
View .gitlab-ci.yml
build:install-vendor:
stage: build
image: <any-image-with-composer>
before_script:
- composer config -g cache-dir "$(pwd)/.composer-cache"
script:
- composer install --ignore-platform-reqs --no-dev --optimize-autoloader --no-ansi --no-interaction --no-progress
cache:
paths:
- .composer-cache/