Skip to content

Instantly share code, notes, and snippets.

import './assets/emoji-picker.css'
import React, { Component } from 'react'
import { chatsApi, infoApi } from './api'
import AppAside from './AppAside'
import {
preloadDataSuccess as chatsPreloadDataSuccess
@razdvapoka
razdvapoka / withFullState.js
Created April 7, 2017 09:48
withFullState (multiple Recompose.withState composed together)
const capitalize = string =>
`${string.charAt(0).toUpperCase()}${string.slice(1)}`
const withFullState = stateSpec =>
compose(
...Object
.keys(stateSpec)
.map(stateKey =>
withState(
stateKey,
@razdvapoka
razdvapoka / slice that ignores array boundaries
Created March 24, 2017 17:12
slice that ignores array boundaries
const slice = (array, from, to) => {
let realFrom = from < 0 ? array.length + from : from
let realTo = to > array.length ? to - array.length : to
return (realFrom <= realTo
? array.slice(realFrom, realTo)
: array.slice(realFrom, array.length).concat(array.slice(0, realTo))
)
}