diff --git a/app/containers/HomePage/sagas.js b/app/containers/HomePage/sagas.js index 6f955ac850..7e368760e3 100644 --- a/app/containers/HomePage/sagas.js +++ b/app/containers/HomePage/sagas.js @@ -2,6 +2,7 @@ * Gets the repositories of the user from Github */ +import { takeLatest } from 'redux-saga'; import { take, call, put, select, fork, cancel } from 'redux-saga/effects'; import { LOCATION_CHANGE } from 'react-router-redux'; import { LOAD_REPOS } from 'containers/App/constants'; @@ -29,12 +30,11 @@ export function* getRepos() { } /** - * Watches for LOAD_REPOS action and calls handler + * Watches for LOAD_REPOS actions and calls getRepos when one comes in. + * By using `takeLatest` only the result of the latest API call is applied. */ export function* getReposWatcher() { - while (yield take(LOAD_REPOS)) { - yield call(getRepos); - } + yield fork(takeLatest, LOAD_REPOS, getRepos); } /** diff --git a/app/containers/HomePage/tests/sagas.test.js b/app/containers/HomePage/tests/sagas.test.js index 49537ae3c1..2ecbb014ab 100644 --- a/app/containers/HomePage/tests/sagas.test.js +++ b/app/containers/HomePage/tests/sagas.test.js @@ -3,6 +3,7 @@ */ import expect from 'expect'; +import { takeLatest } from 'redux-saga'; import { take, call, put, select, fork, cancel } from 'redux-saga/effects'; import { LOCATION_CHANGE } from 'react-router-redux'; @@ -58,12 +59,7 @@ describe('getReposWatcher Saga', () => { it('should watch for LOAD_REPOS action', () => { const takeDescriptor = getReposWatcherGenerator.next().value; - expect(takeDescriptor).toEqual(take(LOAD_REPOS)); - }); - - it('should invoke getRepos saga on actions', () => { - const callDescriptor = getReposWatcherGenerator.next(put(LOAD_REPOS)).value; - expect(callDescriptor).toEqual(call(getRepos)); + expect(takeDescriptor).toEqual(fork(takeLatest, LOAD_REPOS, getRepos)); }); }); @@ -83,10 +79,10 @@ describe('githubDataSaga Saga', () => { }); it('should finally cancel() the forked getReposWatcher saga', - function* githubDataSagaCancellable() { + function* githubDataSagaCancellable() { // reuse open fork for more integrated approach - forkDescriptor = githubDataSaga.next(put(LOCATION_CHANGE)); - expect(forkDescriptor.value).toEqual(cancel(forkDescriptor)); - } - ); + forkDescriptor = githubDataSaga.next(put(LOCATION_CHANGE)); + expect(forkDescriptor.value).toEqual(cancel(forkDescriptor)); + } + ); }); diff --git a/app/containers/LanguageProvider/index.js b/app/containers/LanguageProvider/index.js index 1e2a7463c4..afdab2fcdb 100644 --- a/app/containers/LanguageProvider/index.js +++ b/app/containers/LanguageProvider/index.js @@ -15,7 +15,7 @@ import { selectLocale } from './selectors'; export class LanguageProvider extends React.Component { // eslint-disable-line react/prefer-stateless-function render() { return ( - + {React.Children.only(this.props.children)} ); diff --git a/docs/general/deployment.md b/docs/general/deployment.md index 5dc790e29b..193f7ea23d 100644 --- a/docs/general/deployment.md +++ b/docs/general/deployment.md @@ -8,7 +8,7 @@ *Step 2:* Install heroku's buildpack on your heroku app by running the following command: `heroku buildpacks:set https://github.com/heroku/heroku-buildpack-nodejs#v90 -a [your app name]`. Make sure to replace `#v90` with whatever the latest buildpack is which you can [find here](https://github.com/heroku/heroku-buildpack-nodejs/releases). -*Step 3:* Add this line to your Package.json file in the scripts area: `"postinstall": "npm run build:clean",`. This is because Heroku runs this as part of their build process (more of which you can [read about here](https://devcenter.heroku.com/articles/nodejs-support#build-behavior)). +*Step 3:* Add this line to your Package.json file in the scripts area: `"postinstall": "npm run build:clean",`. This is because Heroku runs this as part of their build process (more of which you can [read about here](https://devcenter.heroku.com/articles/nodejs-support#build-behavior)). Then remove this line from your `package.json` file from the scripts area: `"prebuild": "npm run build:clean && npm run test",`, to avoid having Heroku try to run Karma in its dynamo. *Step 4:* Have heroku build your static files when deploying. Add this line to your Package.json file in the scripts area: `"heroku-postbuild": "npm run build",`. ([read about heroku-postbuild here](https://devcenter.heroku.com/articles/nodejs-support#heroku-specific-build-steps)). diff --git a/internals/templates/languageProvider/languageProvider.js b/internals/templates/languageProvider/languageProvider.js index b18a1eb758..17e700e98a 100644 --- a/internals/templates/languageProvider/languageProvider.js +++ b/internals/templates/languageProvider/languageProvider.js @@ -15,7 +15,7 @@ import { selectLocale } from './selectors'; export class LanguageProvider extends React.Component { // eslint-disable-line react/prefer-stateless-function render() { return ( - + {React.Children.only(this.props.children)} ); diff --git a/internals/webpack/webpack.base.babel.js b/internals/webpack/webpack.base.babel.js index 339c128a47..1081ef48b1 100644 --- a/internals/webpack/webpack.base.babel.js +++ b/internals/webpack/webpack.base.babel.js @@ -98,6 +98,7 @@ module.exports = (options) => ({ mainFields: [ 'browser', 'jsnext:main', + 'browser', 'main', ], },