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
| const store = createStore( | |
| reducer, | |
| applyMiddleware(thunk.withExtraArgument(analytics)) | |
| ) | |
| // later | |
| function fetchUser(id) { | |
| return (dispatch, getState, analytics) => { | |
| analytics.track(...); | |
| } |
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
| const store = createStore( | |
| reducer, | |
| applyMiddleware(thunk.withExtraArgument({analytics, api})) | |
| ) | |
| // later | |
| function fetchUser(id) { | |
| return (dispatch, getState, {analytics, api}) => { | |
| api.fetchUser().then(user => { | |
| analytics.track(...); |
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
| export function fetchUser(id) { | |
| return (dispatch, getState, {analytics, api}) => { | |
| return api.fetchUser().then(user => { | |
| analytics.track(...); | |
| }) | |
| } | |
| } |
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
| const store = createStore( | |
| reducer, | |
| applyMiddleware(thunk.withExtraArgument({analytics: () => window.analytics})) | |
| ) | |
| // later | |
| function fetchUser(id) { | |
| return (dispatch, getState, {analytics}}) => { | |
| analytics().track(...); | |
| } |
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
| const injectMiddleware = (staticDeps, dynamicDeps) => ({ dispatch, getState }) => next => action => { | |
| const deps = {...staticDeps}; | |
| Object.keys(dynamicDeps).forEach(key => { | |
| deps[key] = dynamicDeps[key](); | |
| }); | |
| return next(typeof action === 'function' | |
| ? action({ ...deps, dispatch, getState }) | |
| : 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
| import React from 'react' | |
| import { noop } from 'lodash' | |
| import hoistStatics from 'hoist-non-react-statics' | |
| import { getServerErrorMessage } from '../../lib/serverErrorUtils' | |
| import PropTypes from "prop-types" | |
| function getDisplayName(WrappedComponent) { | |
| return WrappedComponent.displayName || WrappedComponent.name || 'Component' | |
| } |
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, { AnchorHTMLAttributes } from 'react' | |
| import { NavLink, NavLinkProps } from 'react-router-dom' | |
| const Link: React.SFC<NavLinkProps | AnchorHTMLAttributes> = props => { | |
| if (props.to) { | |
| return <NavLink {...props} /> | |
| } | |
| return <a {...props} /> | |
| } |
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 { css, cx } from 'react-emotion' | |
| import { NavLinkProps } from 'react-router-dom' | |
| import NavLink from '../NavLink/NavLink' | |
| const linkClassName = css` | |
| color: blue; | |
| ` |
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 styled from 'react-emotion' | |
| import { bool } from 'prop-types' | |
| import isPropValid from '@emotion/is-prop-valid' | |
| import { | |
| fontSize, | |
| color, | |
| textAlign, | |
| fontWeight, | |
| hover, | |
| propTypes, |