Skip to content

Instantly share code, notes, and snippets.

import React, {Component, PureComponent} from 'react';
import PropTypes from 'prop-types';
import { spring, Motion, presets } from 'react-motion';
import Modal from 'react-modal';
const portalClassName = "modal-portal";
const bodyOpenClassName = "modal-opened";
export const MODAL_VERTICAL_POSITIONS = {
TOP: 'top',
@romanlex
romanlex / redux-is-smarter-than-you-think.md
Created December 1, 2017 12:50 — forked from armw4/redux-is-smarter-than-you-think.md
Optimizing your react components via redux....shouldComponentUpdate for free and more...

The Beginning

Yes...it's true...redux is smart....smarter than you even know. It really does want to help you. It strives to be sane and easy to reason about. With that being said, redux gives you optimizations for free that you probably were completely unaware of.

connect()

connect is the most important thing in redux land IMO. This is where you tie the not between redux and your underlying components. You usually take state and propogate it down your component hiearchy in the form of props. From there, presentational

@romanlex
romanlex / introrx.md
Created December 6, 2017 11:38 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
package main
import (
"io/ioutil"
"log"
"fmt"
"os"
"sync"
"path/filepath"
"os/exec"
"eslintConfig": {
"env": {
"browser": true,
"jquery": true,
"es6": true,
"node": true
},
"extends": [
"plugin:react/recommended",
"plugin:jsx-a11y/recommended",
const emptyCounterparties = [];
const emptyProducts = [];
/** Список банков */
export const getCounterparties = (state) => state.orders.data.counterparties;
/** Конкретный банк */
export const getCounterparty = (state, props) =>
state.orders.data.counterparties[props.bankId] || null;
{
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'app',
async: 'common',
children: true,
deepChildren: true,
minChunks: (module, count) => {
return count >= 3 && module.context && !module.context.includes('node_modules');
},
@romanlex
romanlex / generateFlowModuleNameMappers.js
Created May 17, 2018 12:19 — forked from turadg/generateFlowModuleNameMappers.js
Helper to create .flowconfig module name mapper
#!/usr/bin/env node
/**
* Flowtype understands Node (or Haste) imports but not Webpack.
*
* Many codebases have webpack set up like:
* src/foo.js
* src/components/Bar.jsx
*
* And then import them like `require('foo')` or `require/components/Bar.jsx`
*
[ignore]
<PROJECT_ROOT>/app/*
<PROJECT_ROOT>/bin/*
<PROJECT_ROOT>/config/*
<PROJECT_ROOT>/db/*
<PROJECT_ROOT>/doc/*
<PROJECT_ROOT>/dockerfiles/*
<PROJECT_ROOT>/engines/*
<PROJECT_ROOT>/kubernetes/*
<PROJECT_ROOT>/lib/*
@romanlex
romanlex / fetch.js
Last active June 4, 2018 11:33
Fetch multiple urls with fetch and save multiple response data
const RAW_CONTENT_TYPES = ['image/svg+xml']
/**
* Fetch url
*
* @param {string} url
*/
export const fetchResources = url => fetch(url, {
credentials: 'same-origin',
}).then((response) => {