Skip to content

Instantly share code, notes, and snippets.

import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { kea } from 'kea'
@kea({
actions: () => ({
increment: (amount) => ({ amount }),
decrement: (amount) => ({ amount })
}),
import React, { Component } from 'react'
export default class Counter extends Component {
constructor (props) {
this.state = {
counter: 0
}
}
handleIncrement = (amount) => {
import './styles.scss'
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { kea } from 'kea'
const books = {
1: 'book1',
2: 'book2'
}
import './styles.scss'
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { kea } from 'kea'
const books = {
1: 'book1',
2: 'book2'
}
@mariusandra
mariusandra / connect.jsx
Last active July 4, 2017 06:18
inline kea
import React, { Component } from 'react'
import { connect, inline } from 'kea/logic'
import { put } from 'redux-saga/effects'
import someLogic from './some/logic'
@connect({
actions: [
someLogic, [
'doSomething'
@mariusandra
mariusandra / 7bit-sms.rb
Created February 23, 2017 11:12
7-bit sms character set
SMS_7BIT_CHARACTERS = [
# Standard Latin Characters
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
# Numbers
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
@mariusandra
mariusandra / logic.js
Last active December 7, 2016 07:17
kea/logic example
// see the accompanying kea/saga example here: https://gist.github.com/mariusandra/e6091b393e153c9edf3ba451a9d91aeb
import Logic from 'kea/logic'
import { PropTypes } from 'react'
import { initFromProps } from '~/scenes/index'
class InboxThreadLogic extends Logic {
path = () => ['scenes', 'inboxThread', 'index']
@mariusandra
mariusandra / saga.js
Last active December 5, 2016 18:26
kea/saga example
// see the accompanying kea/logic example here: https://gist.github.com/mariusandra/1b8eeb3f2f4e542188b915e27133c858
import Saga from 'kea/saga'
import sceneLogic from './logic'
export default class InboxThreadSaga extends Saga {
// pick actions from logic stores
actions = () => ([
sceneLogic, [
'makeBookingRequest',
@mariusandra
mariusandra / helmet.js
Created December 1, 2016 14:38
react-helmet with react_on_rails server side rendering
import React, { Component, PropTypes } from 'react'
import ReactHelmet from 'react-helmet'
class PlainComponent extends Component {
render () {
return null
}
}
export default class Helmet extends Component {
const mapping = {
// `id` passed as regular prop
actions: [
areasLogic, [
'setAreaHover#id',
'clearAreaHover',
'editArea#id',
'clearSelection'
]