- FOSS Sea 2013 - "Как использовать PaaS Heroku"
- ...
This file contains 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 { RefObject, useRef } from 'react'; | |
// custom react hook to implement blur logic on click event | |
// function returns ref and callback | |
// ref should be set to anchor, e.g. <a ref={ref} ...></a> | |
// callback should be called without params in onClick handler, | |
// e.g. <a onClick={(e)=> { forceBlur(); ... } /> | |
export function useForceBlur(): [RefObject<HTMLAnchorElement>, () => void] { | |
const ref = useRef<HTMLAnchorElement>(null); | |
const forceBlur = () => { |
This file contains 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
const fetchMachine = Machine({ | |
id: 'fetch', | |
initial: 'unverified', | |
context: { | |
smsBlockVisible: false, | |
verifyCodeButtonDisabled: true, | |
phoneNumberInputReadOnly: false, | |
sendCodeButtonVisible: true, | |
unlinkPhoneButtonVisible: false, | |
successMessage: 'undefined', |
This file contains 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
function memoize(func) { | |
const map = new Map() | |
return function() { | |
const args = Array.prototype.slice.call(arguments) | |
const key = JSON.stringify(args) | |
if (! map.has(key)) map.set(key, func.apply(null, args)) | |
return map.get(key) | |
} | |
} |
This file contains 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 example of a test for a Control Component inside of Redux Form | |
*/ | |
import React from 'react'; | |
import ComponentToBeTested from '../ComponentToBeTested'; | |
import configureStore from 'redux-mock-store'; | |
import { Provider } from 'react-redux'; | |
import { mount } from 'enzyme'; | |
import { reduxForm } from 'redux-form'; |
This file contains 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 * as types from '../actions/actionTypes' | |
import initialState from './initialState' | |
export default function $NAME(state = initialState.$NAME, action) { | |
switch (action.type) { | |
case types.: | |
return state; | |
default: | |
return state; | |
} |
This file contains 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 expect from 'expect'; | |
import {shallow, mount} from 'enzyme' | |
import {$NAME} from './$NAME' | |
describe('<$NAME />', ()=>{ | |
function setup() { | |
let props = { | |
actions: { someAction: () => Promise.resolve() } |
This file contains 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, Component } from 'react'; | |
class $NAME extends Component { | |
render() { | |
return ( | |
); | |
} | |
} |
This file contains 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'; | |
const $NAME = (props) => { | |
return ( | |
$END | |
); | |
} | |
$NAME.propTypes = { | |
// myProp: PropTypes.string.isRequired |
This file contains 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, Component } from 'react'; | |
import { connect } from 'react-redux'; | |
import { bindActionCreators } from 'redux'; | |
// Import actions here!! | |
class $NAME extends Component { | |
constructor(props, context) { | |
super(props, context); | |
} |