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 configureMockStore from 'redux-mock-store'; | |
import thunk from 'redux-thunk'; | |
import { middleware as reduxPackMiddleware } from 'redux-pack'; | |
import * as Cookies from 'js-cookie'; | |
import nock from 'nock'; | |
import httpAdapter from 'axios/lib/adapters/http'; | |
import API from '../../services/api'; | |
import { login } from '../authentication'; |
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 _ from 'lodash'; | |
const ourArray = [ | |
{first_name: 'Marcin', last_name: 'Brukiewicz', age: 24}, | |
{first_name: 'Marta', last_name: 'Brukiewicz', age: 24}, | |
{first_name: 'Test', last_name: 'xyz', age: 56} | |
]; | |
_.sortBy(ourArray, ['last_name', 'first_name']); |
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
// Example file showing how to structure file responsible for API connection (with the use of `axios` library) | |
import axios from 'axios'; | |
export class Fetch { | |
static type = { | |
singular: 'singular', | |
list: 'list', | |
}; |
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 _ from 'lodash'; | |
import { | |
withState, | |
compose, | |
lifecycle, | |
} from 'recompose'; | |
const withErrorCatch = ErrorComponent => compose( | |
withState('errorComponent', 'setErrorComponent', null), |
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 { injectIntl } from 'react-intl'; | |
const withIntl = (WrappedComponent) => { | |
const Component = injectIntl((props) => { | |
const { intl } = props; | |
// For shorter syntax - similar to `react-i18n` | |
const t = (id, values) => intl.formatMessage({ id }, values); | |
return ( | |
<WrappedComponent {...props} t={t} /> |
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 { TweenOneGroup } from 'rc-tween-one'; | |
const defaults = { | |
durations: { | |
in: 300, | |
out: 300, | |
width: 300, | |
}, | |
easings: { |
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
// Purposes: | |
// 1. For reseting a state on componentWillUnmount | |
// 2. For refetching data when :id in URL is changed | |
// It uses RequestCancellation from another gist file. More info here: | |
// https://stackoverflow.com/questions/52607886/react-requests-cancellation-on-page-change | |
import _ from 'lodash'; | |
import { connect } from 'react-redux'; | |
import { compose, lifecycle } from 'recompose'; | |
import RequestCancelation from '../services/requestCancelation'; |
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
// I described my problem on https://stackoverflow.com/questions/52607886/react-requests-cancellation-on-page-change/52610800#52610800 | |
// and worked my way through it | |
import _ from 'lodash'; | |
import axios from 'axios'; | |
// history should be imported from a file where it's created | |
import { history } from '../app/setup'; | |
class RequestCancelation { |
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
// Credit to https://github.com/yahoo/react-intl/issues/416#issuecomment-376088833 | |
// This is a provider that should be a direct child of <IntlProvider> from 'react-intl'. | |
// Example of wrapping the code: | |
// <IntlProvider {...someConfigProps}> | |
// <GlobalIntlProvider> | |
// <AppLayout /> | |
// </GlobalIntlProvider> | |
// </IntlProvider> |
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
// Cache should work in a way that it takes into consideration: | |
// 1. Page number and page size | |
// 2. Applied filters | |
// Other assumptions: | |
// 1. It should be stored for up to 5 minutes - for quick access (TODO: TBD) | |
// 2. It should use localStorage | |
import _ from 'lodash'; | |
import moment from 'moment'; | |
import LS from '../../../utils/localStorage'; // Available here https://gist.github.com/Ancinek/86d2c136a04c010811d295fb2fb2deab |
OlderNewer