This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createAction, createAsyncAction, createReducer, ActionReturnTypes, createSelector } from 'redux-typekit' | |
import { Issue } from '@mm-backend/issues/model' | |
export const selector = 'issues' | |
export const actions = { | |
add: createAction<'issues/ADD', { issue: Issue }>('issues/ADD'), | |
} | |
export type actions = ActionReturnTypes<typeof actions> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is how I would traditionally do it | |
export const selector = 'toasts' | |
export const actionTypes = { | |
ADD: `${selector}/ADD`, | |
SHOW: `${selector}/SHOW`, | |
HIDE: `${selector}/HIDE`, | |
} | |
export const reducer = (state = {}, action) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is an automated testing file for this repo: https://github.com/ConsenSys-Academy/event-ticket-exercise | |
var EventTicketsV2 = artifacts.require('EventTicketsV2') | |
let catchRevert = require("./exceptionsHelpers.js").catchRevert | |
contract('EventTicketV2', function(accounts) { | |
const deployAccount = accounts[0] | |
const firstAccount = accounts[3] | |
const secondAccount = accounts[4] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"posts": [ | |
{ | |
"id": 17257143, | |
"title": "Learn Reinforcement Learning from scratch", | |
"points": 66, | |
"user": "e_ameisen", | |
"time": 1528387842, | |
"time_ago": "an hour ago", | |
"comments_count": 1, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// want to be able to ensure that the second param (key) exists as a key on the objects of the first type (array) | |
export const arrayToKeyedObj = (array: Array<{}>, key: string): {} => { | |
return array.reduce((acc, item) => { | |
acc[item[key]] = item | |
return acc | |
}, {}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Uses Context and transforms string values ('tiny' => 4px) | |
connectToStyles(({ padding }) => { | |
table: { | |
...padding({ left: ‘tiny’ }) | |
} | |
)) | |
// Uses Context and passes values for use explicitly | |
connectToStyles(({ padding, sizes }) => { | |
table: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { mount } from 'enzyme' | |
// Should Focus | |
const input = mount(<EdibleInput focusHexInputOnMount />); | |
assert(input.find('input').node === document.activeElement); | |
// Shouldn't Focus | |
const input = mount(<EdibleInput focusHexInputOnMoun={ false } />); | |
assert(input.find('input').node !== document.activeElement); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { connect } from 'react-redux' | |
import { store } from 'new-package' | |
import { reducer, path, actions, selectors } from './actions' | |
const Tabs ({ activeIndex, select }) => { | |
// Only register the reducer when tabs is used | |
store.register(path, reducer) | |
return ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import reactCSS from 'reactcss' | |
import { connect } from 'react-redux' | |
import { actions, selectors } from './reducer' | |
export const Popup = ({ children, visible, onClose, name }) => { | |
const styles = reactCSS({ | |
'default': { | |
wrap: { | |
position: 'absolute', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { PropTypes } from 'react'; | |
import { Hoverable } from '@bufferapp/redux-hover'; | |
const MyComponent = ({ | |
hovered, // managed by redux-hover | |
onMouseEnter, | |
onMouseLeave, | |
}) => | |
<div | |
onMouseEnter={onMouseEnter} |
NewerOlder