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 React = require('react'); | |
const createFocusTrap = require('focus-trap'); | |
const checkedProps = [ | |
'active', | |
'paused', | |
'tag', | |
'focusTrapOptions', | |
'_createFocusTrap' | |
]; |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 { mount as realMount, shallow as realShallow, render as realRender } from 'enzyme'; | |
const proxyfy = (wrapper, settings = {}) => new Proxy(wrapper, { | |
get(target, prop) { | |
// update first | |
if (prop !== 'update' && !settings.child) { | |
if (target.update) { | |
target.update(); | |
} | |
} |
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 { connect } from 'react-redux'; | |
import reduxSemaphore from 'react-redux-semaphore'; | |
import reduxFocus from 'react-redux-focus'; | |
// a + b = c. That a LAW! | |
const AddLaw = ({a, b, sum}) => <div>{a} + {b} = {sum}</div> | |
// ok, we will connect this component to a Redux store to get a data. Why not? | |
const ConnectedRender = connect( | |
({a, b, sum}) => ({a, b, sum}) |
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 addAandB = memoize( (a,b) => a + b ); | |
addAandB(1,1)// refresh | |
addAandB(1,1)// memoized | |
addAandB(1,2)// refresh |
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 getVisibleTodos = (state, props) => | |
switch (state.visibilityFilter) { | |
case 'SHOW_COMPLETED': return state.todos.filter(todo => todo.completed) | |
case 'SHOW_ACTIVE': return state.todos.filter(todo => !todo.completed) | |
default: return todos | |
} | |
const mapStateToProps = (state, props) => { | |
return { | |
todos: memoize(getVisibleTodos(state, props)) |
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 Memoize from 'react-memoize'; | |
<Memoize | |
prop1 = "theKey" | |
state = {this.state} | |
compute={ ({prop1, state}) => heavyComputation(state[prop1]) } | |
> | |
{ result => <Display>Result is: {result}</Display> } | |
</Memoize> |
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 heavyFunction = (state) => ({ | |
a: state.a.b.c, | |
b: state.a.b | |
}); |
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 {theDay} from 'doom-scheduler' | |
import {Launch} from './rocket-silo'; | |
theDay | |
.then(Launch) | |
.then( () => alert(' :) '), | |
() => alert(' :( next time, you know...'); |
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 td from 'testdouble'; | |
const {Launch} = td.replace('./rocket-silo'); // automock | |
const scheduler = td.replace('doom-scheduler', { theDay: Promise.resolve() }) | |
require('./dooms-day.js'); | |
td.verify(Launch()); |
OlderNewer