Skip to content

Instantly share code, notes, and snippets.

@8lane
8lane / .js
Created October 6, 2018 16:44
const movies = state.movies.map((movie) => {
if (movie.id === action.payload.id) {
return {
...movie,
count: action.payload.count
}
}
return movie
})
import React from 'react'
import { Provider, connect } from 'react-redux'
import { createStore, applyMiddleware } from 'redux'
import { composeWithDevTools } from 'redux-devtools-extension'
import createSagaMiddleware from 'redux-saga'
import PropTypes from 'prop-types'
import 'regenerator-runtime/runtime'
/* Core Sagas & Socket Sagas */
import { Reducers, Sagas as coreSagas } from './Core'
import Immutable from 'seamless-immutable'
import { createReducer } from 'reduxsauce'
import { Types } from './actions'
export const INITIAL_STATE = Immutable({
agentsOnline: 0,
estimatedWaitTime: null,
estimatedWaitTimeConnecting: false,
estimatedWaitTimeAttempts: 0,
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`When displaying the Chat Header component should display correctly 1`] = `
<header
className="lc-header"
data-test="lc-header"
>
<button
className="lc-header__close-btn"
data-test="lc-header__close-btn"
@8lane
8lane / saga.js
Last active October 2, 2018 11:44
/* eslint-disable no-param-reassign */
import { eventChannel, delay } from 'redux-saga'
import { all, take, call, put, race, select, takeEvery } from 'redux-saga/effects'
import { Messages } from '../Socket'
import { ControlsCreators, SocketCreators } from '../../actions'
import { formatAttributesToArray } from '../Api/helpers'
@8lane
8lane / server.js
Created August 11, 2018 16:33
NextJS sitemap.xml & robots.txt
const { createServer } = require('http')
const { parse } = require('url')
const next = require('next')
const express = require('express')
const app = next({dev: process.env.NODE_ENV !== 'production'})
const handler = app.getRequestHandler()
app.prepare().then(() => {
const server = express();
0x5261e31F06dd599647050197d153e881Ec2fAFc9
(function(){
console.log('window? ', window);
})(window);
@8lane
8lane / ErrorBoundary.jsx
Created January 22, 2018 11:49
React 16 componentDidCatch Jest/Enzyme unit test
import React from 'react'
import PropTypes from 'prop-types'
class ErrorBoundary extends React.Component {
constructor (props) {
super(props)
this.state = { hasError: false }
}
componentDidCatch (error, info) {
/*!
* Bootstrap v4.0.0-alpha.6 (https://getbootstrap.com)
* Copyright 2011-2017 The Bootstrap Authors
* Copyright 2011-2017 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
// Core variables and mixins
@import "node_modules/bootstrap/scss/variables";
@import "node_modules/bootstrap/scss/mixins";