Skip to content

Instantly share code, notes, and snippets.

View efleurine's full-sized avatar
💭
working remotly

Emmanuel efleurine

💭
working remotly
View GitHub Profile
@slikts
slikts / react-memo-children.md
Last active April 27, 2024 02:44
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
@bvaughn
bvaughn / eager-prefetching-async-data-example.js
Last active November 30, 2022 21:16
Advanced example for eagerly prefetching async data in a React component.
// This is an advanced example! It is not intended for use in application code.
// Libraries like Relay may make use of this technique to save some time on low-end mobile devices.
// Most components should just initiate async requests in componentDidMount.
class ExampleComponent extends React.Component {
_hasUnmounted = false;
state = {
externalData: null,
};
@oukayuka
oukayuka / UserSearchForm.tsx
Last active October 10, 2021 08:34
Formik sample with TypeScript
import { InjectedFormikProps, withFormik } from 'formik';
import * as React from 'react';
import * as Yup from 'yup';
interface FormValues {
login: string;
}
interface FormProps {
login?: string;
@tkh44
tkh44 / reset-styles.js
Created September 27, 2017 05:50
glamor reset for emotion
import { injectGlobal } from 'react-emotion';
/*! normalize.css v5.0.0 | MIT License | github.com/necolas/normalize.css */
/**
* 1. Change the default font family in all browsers (opinionated).
* 2. Correct the line height in all browsers.
* 3. Prevent adjustments of font size after orientation changes in
* IE on Windows Phone and in iOS.
*/
@Pulimet
Pulimet / AdbCommands
Last active May 3, 2024 10:59
Adb useful commands list
adb help // List all comands
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
@jniltinho
jniltinho / install_php55_ubuntu.sh
Last active May 19, 2023 15:12
Install PHP 5.5.38 on Ubuntu 16.04 64Bits
#!/bin/bash
### Install PHP 5.5.38 on Ubuntu 16.04 64Bits
### https://www.howtoforge.com/tutorial/how-to-install-php-5-6-on-ubuntu-16-04/
apt-get -y install build-essential libxml2-dev libxslt1-dev
apt-get -y install libfcgi-dev libfcgi0ldbl libjpeg62-dbg libxml2-dev
apt-get -y install libmcrypt-dev libssl-dev libc-client2007e libc-client2007e-dev
apt-get -y install libbz2-dev libcurl4-openssl-dev libjpeg-dev libpng12-dev
apt-get -y install libfreetype6-dev libkrb5-dev libpq-dev libicu-dev
@ivan-loh
ivan-loh / install-watchman.sh
Last active January 27, 2022 13:02
Watchman ( 4.9.0 ) installation for Ubuntu 16.04
# checkout, compile & install
git clone https://github.com/facebook/watchman.git
cd watchman/
git checkout v4.9.0
sudo apt-get install -y autoconf automake build-essential python-dev libssl-dev libtool
./autogen.sh
./configure
make
sudo make install
@davidgljay
davidgljay / ComponentIndex.js
Last active June 12, 2022 19:22
Pattern for dynamically loading React components based on a config json object.
import config from '../config'
let components = {}
//For each component in the config fiel into an object
for (var i = config.length - 1; i >= 0; i--) {
components[config[i].name] = require(config[i].path).default
}
export default components
@henriquemenezes
henriquemenezes / android-generate-keystores.md
Last active May 2, 2024 21:33
Android: Generate Release/Debug Keystores

Android: Generate Release/Debug Keystores

Generate Keystores

Debug Keystore

$ keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "C=US, O=Android, CN=Android Debug"