├── .gitignore ├── Chapter05 ├── scripts │ └── start.js ├── app │ ├── containers │ │ ├── User │ │ │ ├── style.css │ │ │ ├── Loadable.js │ │ │ └── index.js │ │ ├── AboutPage │ │ │ ├── Loadable.js │ │ │ ├── __tests__ │ │ │ │ ├── __snapshots__ │ │ │ │ │ ├── index-test.js.snap │ │ │ │ │ └── redirect-test.js.snap │ │ │ │ ├── index-test.js │ │ │ │ └── redirect-test.js │ │ │ ├── index.js │ │ │ └── redirect.js │ │ ├── HomePage │ │ │ ├── Loadable.js │ │ │ ├── __tests__ │ │ │ │ ├── index-test.js │ │ │ │ └── __snapshots__ │ │ │ │ │ └── index-test.js.snap │ │ │ └── index.js │ │ ├── Login │ │ │ ├── Loadable.js │ │ │ ├── __tests__ │ │ │ │ ├── __snapshots__ │ │ │ │ │ └── index-test.js.snap │ │ │ │ └── index-test.js │ │ │ ├── style.css │ │ │ ├── constants.js │ │ │ ├── actions.js │ │ │ └── index.js │ │ ├── Register │ │ │ ├── Loadable.js │ │ │ ├── __tests__ │ │ │ │ ├── __snapshots__ │ │ │ │ │ └── index-test.js.snap │ │ │ │ └── index-test.js │ │ │ ├── constants.js │ │ │ ├── style.css │ │ │ ├── actions.js │ │ │ └── index.js │ │ ├── ContactPage │ │ │ ├── Loadable.js │ │ │ └── index.js │ │ ├── NotFoundPage │ │ │ ├── Loadable.js │ │ │ └── index.js │ │ └── App │ │ │ └── reducer.js │ ├── images │ │ ├── favicon.ico │ │ └── icon-512x512.png │ ├── components │ │ ├── Header │ │ │ ├── logo.png │ │ │ ├── bgheader.png │ │ │ ├── A.js │ │ │ ├── HeaderBg.js │ │ │ ├── tests │ │ │ │ ├── __snapshots__ │ │ │ │ │ ├── A.test.js.snap │ │ │ │ │ └── Img.test.js.snap │ │ │ │ └── index.test.js │ │ │ ├── Logo.js │ │ │ ├── NavBar.js │ │ │ ├── HeaderLink.js │ │ │ └── index.js │ │ ├── H1 │ │ │ ├── index.js │ │ │ └── tests │ │ │ │ └── index.test.js │ │ ├── LoadingIndicator │ │ │ ├── Wrapper.js │ │ │ └── index.js │ │ ├── Footer │ │ │ ├── Wrapper.js │ │ │ └── index.js │ │ ├── A │ │ │ └── index.js │ │ └── Img │ │ │ └── index.js │ ├── utils │ │ ├── history.js │ │ └── checkStore.js │ ├── reducers.js │ ├── configureStore.js │ ├── global-styles.js │ └── app.js ├── testing │ ├── test-bundler.js │ ├── mocks │ │ ├── image.js │ │ └── cssModule.js │ └── enzyme-setup.js ├── server │ ├── argv.js │ ├── port.js │ ├── middlewares │ │ └── frontendMiddleware.js │ └── index.js ├── .prettierrc ├── .gitignore ├── .editorconfig ├── readme.MD ├── jest.config.js └── babel.config.js ├── starter ├── scripts │ └── start.js ├── app │ ├── containers │ │ ├── HomePage │ │ │ ├── Loadable.js │ │ │ └── index.js │ │ ├── NotFoundPage │ │ │ ├── Loadable.js │ │ │ └── index.js │ │ └── App │ │ │ ├── selectors.js │ │ │ ├── index.js │ │ │ └── constants.js │ ├── utils │ │ ├── history.js │ │ ├── constants.js │ │ └── checkStore.js │ ├── reducers.js │ └── configureStore.js ├── .editorconfig ├── .gitignore └── babel.config.js ├── Chapter06 ├── .nvmrc ├── testing │ ├── mocks │ │ ├── image.js │ │ └── cssModule.js │ ├── test-bundler.js │ └── enzyme-setup.js ├── nodemon.json ├── server │ ├── argv.js │ ├── port.js │ ├── helpers │ │ ├── prototype.js │ │ └── jwt.js │ ├── middlewares │ │ ├── frontendMiddleware.js │ │ └── addProdMiddlewares.js │ └── models │ │ ├── questions.js │ │ ├── organizations.js │ │ └── index.js ├── .prettierignore ├── app │ ├── containers │ │ ├── App │ │ │ ├── constants.js │ │ │ ├── actions.js │ │ │ ├── tests │ │ │ │ ├── actions.test.js │ │ │ │ └── reducer.test.js │ │ │ ├── style.css │ │ │ ├── saga.js │ │ │ ├── selectors.js │ │ │ └── reducer.js │ │ ├── LanguageProvider │ │ │ ├── constants.js │ │ │ ├── actions.js │ │ │ ├── selectors.js │ │ │ ├── tests │ │ │ │ ├── selectors.test.js │ │ │ │ ├── actions.test.js │ │ │ │ └── reducer.test.js │ │ │ └── reducer.js │ │ ├── LocaleToggle │ │ │ ├── Wrapper.js │ │ │ └── messages.js │ │ ├── Doctor │ │ │ ├── style.css │ │ │ ├── Loadable.js │ │ │ ├── constants.js │ │ │ ├── messages.js │ │ │ ├── actions.js │ │ │ ├── selectors.js │ │ │ └── reducer.js │ │ ├── Home │ │ │ ├── Loadable.js │ │ │ └── index.js │ │ ├── Register │ │ │ ├── constants.js │ │ │ ├── Loadable.js │ │ │ ├── style.css │ │ │ └── actions.js │ │ ├── User │ │ │ ├── Loadable.js │ │ │ ├── style.css │ │ │ └── index.js │ │ ├── Login │ │ │ ├── Loadable.js │ │ │ ├── style.css │ │ │ ├── constants.js │ │ │ ├── actions.js │ │ │ └── messages.js │ │ └── NotFoundPage │ │ │ ├── Loadable.js │ │ │ ├── messages.js │ │ │ ├── index.js │ │ │ └── tests │ │ │ └── index.test.js │ ├── images │ │ ├── favicon.ico │ │ └── icon-512x512.png │ ├── assets │ │ └── images │ │ │ └── bgheader.png │ ├── components │ │ ├── Header │ │ │ ├── logo.png │ │ │ ├── bgheader.png │ │ │ ├── Logo.js │ │ │ ├── A.js │ │ │ ├── tests │ │ │ │ ├── __snapshots__ │ │ │ │ │ ├── Logo.test.js.snap │ │ │ │ │ ├── A.test.js.snap │ │ │ │ │ └── HeaderBg.test.js.snap │ │ │ │ └── Logo.test.js │ │ │ ├── HeaderBg.js │ │ │ ├── NavBar.js │ │ │ ├── messages.js │ │ │ └── HeaderLink.js │ │ ├── Toggle │ │ │ ├── Select.js │ │ │ └── index.js │ │ ├── LoadingIndicator │ │ │ ├── Wrapper.js │ │ │ ├── tests │ │ │ │ ├── index.test.js │ │ │ │ └── Circle.test.js │ │ │ └── index.js │ │ ├── Footer │ │ │ ├── Wrapper.js │ │ │ ├── tests │ │ │ │ └── __snapshots__ │ │ │ │ │ └── Wrapper.test.js.snap │ │ │ ├── messages.js │ │ │ └── index.js │ │ ├── ToggleOption │ │ │ └── index.js │ │ └── Form │ │ │ └── Fields │ │ │ └── tests │ │ │ ├── index.test.js │ │ │ └── search.test.js │ ├── utils │ │ ├── history.js │ │ ├── constants.js │ │ ├── withIntl.js │ │ ├── checkStore.js │ │ └── request.js │ ├── global-styles.js │ ├── reducers.js │ ├── tests │ │ └── i18n.test.js │ └── configureStore.js ├── .prettierrc ├── .stylelintrc ├── .gitignore ├── scripts │ └── helpers │ │ ├── checkmark.js │ │ └── progress.js ├── .editorconfig ├── README.md └── babel.config.js ├── Chapter07 ├── .nvmrc ├── testing │ ├── mocks │ │ ├── image.js │ │ └── cssModule.js │ ├── test-bundler.js │ └── enzyme-setup.js ├── nodemon.json ├── server │ ├── argv.js │ ├── port.js │ ├── helpers │ │ ├── prototype.js │ │ └── jwt.js │ ├── middlewares │ │ ├── frontendMiddleware.js │ │ └── addProdMiddlewares.js │ └── models │ │ ├── questions.js │ │ ├── organizations.js │ │ └── index.js ├── .prettierignore ├── app │ ├── containers │ │ ├── App │ │ │ ├── constants.js │ │ │ ├── actions.js │ │ │ ├── tests │ │ │ │ ├── actions.test.js │ │ │ │ └── reducer.test.js │ │ │ ├── style.css │ │ │ ├── saga.js │ │ │ ├── selectors.js │ │ │ └── reducer.js │ │ ├── LanguageProvider │ │ │ ├── constants.js │ │ │ ├── actions.js │ │ │ ├── selectors.js │ │ │ ├── tests │ │ │ │ ├── selectors.test.js │ │ │ │ ├── actions.test.js │ │ │ │ └── reducer.test.js │ │ │ └── reducer.js │ │ ├── LocaleToggle │ │ │ ├── Wrapper.js │ │ │ └── messages.js │ │ ├── Doctor │ │ │ ├── style.css │ │ │ ├── Loadable.js │ │ │ ├── constants.js │ │ │ ├── messages.js │ │ │ ├── actions.js │ │ │ ├── selectors.js │ │ │ └── reducer.js │ │ ├── Home │ │ │ ├── Loadable.js │ │ │ └── index.js │ │ ├── Register │ │ │ ├── constants.js │ │ │ ├── Loadable.js │ │ │ ├── style.css │ │ │ └── actions.js │ │ ├── User │ │ │ ├── Loadable.js │ │ │ ├── style.css │ │ │ └── index.js │ │ ├── Login │ │ │ ├── Loadable.js │ │ │ ├── style.css │ │ │ ├── constants.js │ │ │ ├── actions.js │ │ │ └── messages.js │ │ ├── NotFoundPage │ │ │ ├── Loadable.js │ │ │ ├── messages.js │ │ │ ├── index.js │ │ │ └── tests │ │ │ │ └── index.test.js │ │ └── DevTools.js │ ├── images │ │ ├── favicon.ico │ │ └── icon-512x512.png │ ├── assets │ │ └── images │ │ │ └── bgheader.png │ ├── components │ │ ├── Header │ │ │ ├── logo.png │ │ │ ├── bgheader.png │ │ │ ├── Logo.js │ │ │ ├── A.js │ │ │ ├── tests │ │ │ │ ├── __snapshots__ │ │ │ │ │ ├── Logo.test.js.snap │ │ │ │ │ ├── A.test.js.snap │ │ │ │ │ └── HeaderBg.test.js.snap │ │ │ │ └── Logo.test.js │ │ │ ├── HeaderBg.js │ │ │ ├── NavBar.js │ │ │ ├── messages.js │ │ │ └── HeaderLink.js │ │ ├── Toggle │ │ │ ├── Select.js │ │ │ └── index.js │ │ ├── LoadingIndicator │ │ │ ├── Wrapper.js │ │ │ ├── tests │ │ │ │ ├── index.test.js │ │ │ │ └── Circle.test.js │ │ │ └── index.js │ │ ├── Footer │ │ │ ├── Wrapper.js │ │ │ ├── tests │ │ │ │ └── __snapshots__ │ │ │ │ │ └── Wrapper.test.js.snap │ │ │ ├── messages.js │ │ │ └── index.js │ │ ├── ToggleOption │ │ │ └── index.js │ │ └── Form │ │ │ └── Fields │ │ │ └── tests │ │ │ ├── index.test.js │ │ │ └── search.test.js │ ├── utils │ │ ├── history.js │ │ ├── constants.js │ │ ├── withIntl.js │ │ ├── checkStore.js │ │ └── request.js │ ├── global-styles.js │ ├── reducers.js │ └── tests │ │ └── i18n.test.js ├── .prettierrc ├── .stylelintrc ├── .gitignore ├── scripts │ └── helpers │ │ ├── checkmark.js │ │ └── progress.js ├── .editorconfig ├── readme.MD └── babel.config.js ├── Chapter08 ├── .nvmrc ├── nodemon.json ├── server │ ├── argv.js │ ├── port.js │ ├── helpers │ │ ├── prototype.js │ │ └── jwt.js │ ├── logger.js │ └── models │ │ └── index.js ├── .prettierignore ├── .prettierrc ├── .stylelintrc ├── .gitignore ├── .editorconfig ├── readme.MD └── babel.config.js ├── Chapter01 ├── starter │ ├── scripts │ │ └── start.js │ ├── app │ │ ├── containers │ │ │ ├── HomePage │ │ │ │ ├── Loadable.js │ │ │ │ └── index.js │ │ │ ├── NotFoundPage │ │ │ │ ├── Loadable.js │ │ │ │ └── index.js │ │ │ └── App │ │ │ │ └── index.js │ │ ├── utils │ │ │ ├── history.js │ │ │ └── checkStore.js │ │ ├── reducers.js │ │ ├── configureStore.js │ │ └── app.js │ ├── .prettierrc │ ├── .gitignore │ ├── .editorconfig │ └── babel.config.js └── getting-started │ ├── .gitignore │ ├── readme.MD │ ├── babel.config.js │ ├── webpack.config.js │ └── package.json ├── Chapter02 ├── .babelrc ├── .gitignore ├── app │ ├── Redux │ │ ├── actionTypes.js │ │ ├── actionCreators.js │ │ ├── Alerts.js │ │ ├── __tests__ │ │ │ ├── __snapshots__ │ │ │ │ └── AlertContainer-test.js.snap │ │ │ ├── actionCreators-test.js │ │ │ ├── AlertContainer-test.js │ │ │ └── reducers-test.js │ │ ├── AlertContainer.js │ │ └── reducers.js │ ├── JS │ │ ├── calculateBill.js │ │ ├── __tests__ │ │ │ ├── calculateBill-test.js │ │ │ └── time-test.js │ │ └── time.js │ └── React │ │ ├── Logo.js │ │ ├── __tests__ │ │ ├── __snapshots__ │ │ │ ├── HeaderNav-test.js.snap │ │ │ ├── EmailInput-test.js.snap │ │ │ └── Header-test.js.snap │ │ ├── Header-test.js │ │ ├── HeaderNav-test.js │ │ └── EmailInput-test.js │ │ ├── HeaderNav.js │ │ ├── Header.js │ │ ├── SocialMediaLinks.js │ │ └── EmailInput.js ├── readme.MD └── package.json ├── Chapter03 ├── testing │ ├── test-bundler.js │ ├── mocks │ │ ├── image.js │ │ └── cssModule.js │ └── enzyme-setup.js ├── server │ ├── argv.js │ ├── port.js │ ├── middlewares │ │ └── frontendMiddleware.js │ └── index.js ├── app │ ├── images │ │ ├── favicon.ico │ │ └── icon-512x512.png │ ├── containers │ │ ├── AboutPage │ │ │ ├── Loadable.js │ │ │ ├── __tests__ │ │ │ │ ├── __snapshots__ │ │ │ │ │ ├── index-test.js.snap │ │ │ │ │ └── redirect-test.js.snap │ │ │ │ ├── index-test.js │ │ │ │ └── redirect-test.js │ │ │ ├── index.js │ │ │ └── redirect.js │ │ ├── HomePage │ │ │ ├── Loadable.js │ │ │ ├── __tests__ │ │ │ │ ├── index-test.js │ │ │ │ └── __snapshots__ │ │ │ │ │ └── index-test.js.snap │ │ │ └── index.js │ │ ├── Login │ │ │ ├── Loadable.js │ │ │ ├── __tests__ │ │ │ │ ├── __snapshots__ │ │ │ │ │ └── index-test.js.snap │ │ │ │ └── index-test.js │ │ │ └── index.js │ │ ├── Register │ │ │ ├── Loadable.js │ │ │ ├── __tests__ │ │ │ │ ├── __snapshots__ │ │ │ │ │ └── index-test.js.snap │ │ │ │ └── index-test.js │ │ │ └── index.js │ │ ├── ContactPage │ │ │ ├── Loadable.js │ │ │ └── index.js │ │ ├── NotFoundPage │ │ │ ├── Loadable.js │ │ │ └── index.js │ │ └── App │ │ │ └── reducer.js │ ├── utils │ │ └── history.js │ ├── reducers.js │ ├── configureStore.js │ ├── global-styles.js │ └── app.js ├── .prettierrc ├── .gitignore ├── .editorconfig ├── readme.MD ├── jest.config.js └── babel.config.js └── Chapter04 ├── public ├── favicon.ico └── manifest.json ├── src ├── reducers │ └── index.js ├── constants │ └── ActionTypes.js ├── index.html ├── index.js └── actions │ └── todos.js ├── config └── jest │ ├── cssTransform.js │ └── fileTransform.js └── .gitignore /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /Chapter05/scripts/start.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /starter/scripts/start.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Chapter06/.nvmrc: -------------------------------------------------------------------------------- 1 | lts/carbon 2 | -------------------------------------------------------------------------------- /Chapter07/.nvmrc: -------------------------------------------------------------------------------- 1 | lts/carbon 2 | -------------------------------------------------------------------------------- /Chapter08/.nvmrc: -------------------------------------------------------------------------------- 1 | lts/carbon 2 | -------------------------------------------------------------------------------- /Chapter01/starter/scripts/start.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Chapter05/app/containers/User/style.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Chapter02/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | presets: ["env", "react"] 3 | } 4 | -------------------------------------------------------------------------------- /Chapter03/testing/test-bundler.js: -------------------------------------------------------------------------------- 1 | import "@babel/polyfill"; 2 | -------------------------------------------------------------------------------- /Chapter05/testing/test-bundler.js: -------------------------------------------------------------------------------- 1 | import "@babel/polyfill"; 2 | -------------------------------------------------------------------------------- /Chapter02/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | coverage 4 | -------------------------------------------------------------------------------- /Chapter03/testing/mocks/image.js: -------------------------------------------------------------------------------- 1 | module.exports = "IMAGE_MOCK"; 2 | -------------------------------------------------------------------------------- /Chapter05/testing/mocks/image.js: -------------------------------------------------------------------------------- 1 | module.exports = "IMAGE_MOCK"; 2 | -------------------------------------------------------------------------------- /Chapter06/testing/mocks/image.js: -------------------------------------------------------------------------------- 1 | module.exports = "IMAGE_MOCK"; 2 | -------------------------------------------------------------------------------- /Chapter07/testing/mocks/image.js: -------------------------------------------------------------------------------- 1 | module.exports = "IMAGE_MOCK"; 2 | -------------------------------------------------------------------------------- /Chapter03/testing/mocks/cssModule.js: -------------------------------------------------------------------------------- 1 | module.exports = "CSS_MODULE"; 2 | -------------------------------------------------------------------------------- /Chapter05/testing/mocks/cssModule.js: -------------------------------------------------------------------------------- 1 | module.exports = "CSS_MODULE"; 2 | -------------------------------------------------------------------------------- /Chapter06/testing/mocks/cssModule.js: -------------------------------------------------------------------------------- 1 | module.exports = "CSS_MODULE"; 2 | -------------------------------------------------------------------------------- /Chapter07/testing/mocks/cssModule.js: -------------------------------------------------------------------------------- 1 | module.exports = "CSS_MODULE"; 2 | -------------------------------------------------------------------------------- /Chapter01/getting-started/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | *.log 4 | dist 5 | -------------------------------------------------------------------------------- /Chapter02/app/Redux/actionTypes.js: -------------------------------------------------------------------------------- 1 | export const ADD_NEW_DOCTOR = "ADD_NEW_DOCTOR"; 2 | -------------------------------------------------------------------------------- /Chapter06/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "verbose": true, 3 | "ignore": ["app/**"] 4 | } 5 | -------------------------------------------------------------------------------- /Chapter07/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "verbose": true, 3 | "ignore": ["app/**"] 4 | } 5 | -------------------------------------------------------------------------------- /Chapter08/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "verbose": true, 3 | "ignore": ["app/**"] 4 | } 5 | -------------------------------------------------------------------------------- /Chapter03/server/argv.js: -------------------------------------------------------------------------------- 1 | module.exports = require('minimist')(process.argv.slice(2)); 2 | -------------------------------------------------------------------------------- /Chapter05/server/argv.js: -------------------------------------------------------------------------------- 1 | module.exports = require('minimist')(process.argv.slice(2)); 2 | -------------------------------------------------------------------------------- /Chapter06/server/argv.js: -------------------------------------------------------------------------------- 1 | module.exports = require('minimist')(process.argv.slice(2)); 2 | -------------------------------------------------------------------------------- /Chapter07/server/argv.js: -------------------------------------------------------------------------------- 1 | module.exports = require('minimist')(process.argv.slice(2)); 2 | -------------------------------------------------------------------------------- /Chapter08/server/argv.js: -------------------------------------------------------------------------------- 1 | module.exports = require('minimist')(process.argv.slice(2)); 2 | -------------------------------------------------------------------------------- /Chapter06/.prettierignore: -------------------------------------------------------------------------------- 1 | build/ 2 | node_modules/ 3 | package-lock.json 4 | yarn.lock 5 | package.json 6 | -------------------------------------------------------------------------------- /Chapter07/.prettierignore: -------------------------------------------------------------------------------- 1 | build/ 2 | node_modules/ 3 | package-lock.json 4 | yarn.lock 5 | package.json 6 | -------------------------------------------------------------------------------- /Chapter08/.prettierignore: -------------------------------------------------------------------------------- 1 | build/ 2 | node_modules/ 3 | package-lock.json 4 | yarn.lock 5 | package.json 6 | -------------------------------------------------------------------------------- /Chapter06/app/containers/App/constants.js: -------------------------------------------------------------------------------- 1 | export const IS_USER_AUTHENTICATED = 'App/IS_USER_AUTHENTICATED'; 2 | -------------------------------------------------------------------------------- /Chapter07/app/containers/App/constants.js: -------------------------------------------------------------------------------- 1 | export const IS_USER_AUTHENTICATED = 'App/IS_USER_AUTHENTICATED'; 2 | -------------------------------------------------------------------------------- /Chapter06/app/containers/LanguageProvider/constants.js: -------------------------------------------------------------------------------- 1 | export const CHANGE_LOCALE = 'app/LanguageToggle/CHANGE_LOCALE'; 2 | -------------------------------------------------------------------------------- /Chapter07/app/containers/LanguageProvider/constants.js: -------------------------------------------------------------------------------- 1 | export const CHANGE_LOCALE = 'app/LanguageToggle/CHANGE_LOCALE'; 2 | -------------------------------------------------------------------------------- /Chapter04/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Redux-Quick-Start-Guide/HEAD/Chapter04/public/favicon.ico -------------------------------------------------------------------------------- /Chapter03/app/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Redux-Quick-Start-Guide/HEAD/Chapter03/app/images/favicon.ico -------------------------------------------------------------------------------- /Chapter03/server/port.js: -------------------------------------------------------------------------------- 1 | const argv = require('./argv'); 2 | 3 | module.exports = parseInt(argv.port || process.env.PORT || '3000', 10); 4 | -------------------------------------------------------------------------------- /Chapter05/app/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Redux-Quick-Start-Guide/HEAD/Chapter05/app/images/favicon.ico -------------------------------------------------------------------------------- /Chapter05/server/port.js: -------------------------------------------------------------------------------- 1 | const argv = require('./argv'); 2 | 3 | module.exports = parseInt(argv.port || process.env.PORT || '3000', 10); 4 | -------------------------------------------------------------------------------- /Chapter06/app/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Redux-Quick-Start-Guide/HEAD/Chapter06/app/images/favicon.ico -------------------------------------------------------------------------------- /Chapter06/server/port.js: -------------------------------------------------------------------------------- 1 | const argv = require('./argv'); 2 | 3 | module.exports = parseInt(argv.port || process.env.PORT || '3000', 10); 4 | -------------------------------------------------------------------------------- /Chapter07/app/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Redux-Quick-Start-Guide/HEAD/Chapter07/app/images/favicon.ico -------------------------------------------------------------------------------- /Chapter07/server/port.js: -------------------------------------------------------------------------------- 1 | const argv = require('./argv'); 2 | 3 | module.exports = parseInt(argv.port || process.env.PORT || '3000', 10); 4 | -------------------------------------------------------------------------------- /Chapter08/server/port.js: -------------------------------------------------------------------------------- 1 | const argv = require('./argv'); 2 | 3 | module.exports = parseInt(argv.port || process.env.PORT || '3000', 10); 4 | -------------------------------------------------------------------------------- /Chapter01/getting-started/readme.MD: -------------------------------------------------------------------------------- 1 | # Chapter 1 2 | 3 | ## Lists of Topics 4 | 5 | - Need of Redux 6 | - Setting up the Redux 7 | - Redux -Store 8 | -------------------------------------------------------------------------------- /Chapter03/app/containers/AboutPage/Loadable.js: -------------------------------------------------------------------------------- 1 | import loadable from "loadable-components"; 2 | 3 | export default loadable(() => import("./index")); 4 | -------------------------------------------------------------------------------- /Chapter03/app/containers/HomePage/Loadable.js: -------------------------------------------------------------------------------- 1 | import loadable from "loadable-components"; 2 | 3 | export default loadable(() => import("./index")); 4 | -------------------------------------------------------------------------------- /Chapter03/app/containers/Login/Loadable.js: -------------------------------------------------------------------------------- 1 | import loadable from "loadable-components"; 2 | 3 | export default loadable(() => import("./index")); 4 | -------------------------------------------------------------------------------- /Chapter03/app/containers/Register/Loadable.js: -------------------------------------------------------------------------------- 1 | import loadable from "loadable-components"; 2 | 3 | export default loadable(() => import("./index")); 4 | -------------------------------------------------------------------------------- /Chapter03/app/images/icon-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Redux-Quick-Start-Guide/HEAD/Chapter03/app/images/icon-512x512.png -------------------------------------------------------------------------------- /Chapter05/app/containers/AboutPage/Loadable.js: -------------------------------------------------------------------------------- 1 | import loadable from 'loadable-components'; 2 | 3 | export default loadable(() => import('./index')); 4 | -------------------------------------------------------------------------------- /Chapter05/app/containers/HomePage/Loadable.js: -------------------------------------------------------------------------------- 1 | import loadable from "loadable-components"; 2 | 3 | export default loadable(() => import("./index")); 4 | -------------------------------------------------------------------------------- /Chapter05/app/containers/Login/Loadable.js: -------------------------------------------------------------------------------- 1 | import loadable from 'loadable-components'; 2 | 3 | export default loadable(() => import('./index')); 4 | -------------------------------------------------------------------------------- /Chapter05/app/containers/Register/Loadable.js: -------------------------------------------------------------------------------- 1 | import loadable from "loadable-components"; 2 | 3 | export default loadable(() => import("./index")); 4 | -------------------------------------------------------------------------------- /Chapter05/app/images/icon-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Redux-Quick-Start-Guide/HEAD/Chapter05/app/images/icon-512x512.png -------------------------------------------------------------------------------- /Chapter06/app/images/icon-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Redux-Quick-Start-Guide/HEAD/Chapter06/app/images/icon-512x512.png -------------------------------------------------------------------------------- /Chapter07/app/images/icon-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Redux-Quick-Start-Guide/HEAD/Chapter07/app/images/icon-512x512.png -------------------------------------------------------------------------------- /starter/app/containers/HomePage/Loadable.js: -------------------------------------------------------------------------------- 1 | import loadable from "loadable-components"; 2 | 3 | export default loadable(() => import("./index")); 4 | -------------------------------------------------------------------------------- /Chapter02/app/JS/calculateBill.js: -------------------------------------------------------------------------------- 1 | const calculateBill = (totalHours, ratePerHours) => totalHours * ratePerHours; 2 | 3 | module.exports = calculateBill; 4 | -------------------------------------------------------------------------------- /Chapter03/app/containers/ContactPage/Loadable.js: -------------------------------------------------------------------------------- 1 | import loadable from 'loadable-components'; 2 | 3 | export default loadable(() => import('./index')); 4 | -------------------------------------------------------------------------------- /Chapter03/app/containers/NotFoundPage/Loadable.js: -------------------------------------------------------------------------------- 1 | import loadable from "loadable-components"; 2 | 3 | export default loadable(() => import("./index")); 4 | -------------------------------------------------------------------------------- /Chapter03/app/utils/history.js: -------------------------------------------------------------------------------- 1 | import createHistory from 'history/createBrowserHistory'; 2 | const history = createHistory(); 3 | export default history; 4 | -------------------------------------------------------------------------------- /Chapter05/app/components/Header/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Redux-Quick-Start-Guide/HEAD/Chapter05/app/components/Header/logo.png -------------------------------------------------------------------------------- /Chapter05/app/containers/ContactPage/Loadable.js: -------------------------------------------------------------------------------- 1 | import loadable from "loadable-components"; 2 | 3 | export default loadable(() => import("./index")); 4 | -------------------------------------------------------------------------------- /Chapter05/app/containers/NotFoundPage/Loadable.js: -------------------------------------------------------------------------------- 1 | import loadable from "loadable-components"; 2 | 3 | export default loadable(() => import("./index")); 4 | -------------------------------------------------------------------------------- /Chapter05/app/utils/history.js: -------------------------------------------------------------------------------- 1 | import createHistory from 'history/createBrowserHistory'; 2 | const history = createHistory(); 3 | export default history; 4 | -------------------------------------------------------------------------------- /Chapter06/app/assets/images/bgheader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Redux-Quick-Start-Guide/HEAD/Chapter06/app/assets/images/bgheader.png -------------------------------------------------------------------------------- /Chapter06/app/components/Header/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Redux-Quick-Start-Guide/HEAD/Chapter06/app/components/Header/logo.png -------------------------------------------------------------------------------- /Chapter06/app/utils/history.js: -------------------------------------------------------------------------------- 1 | import createHistory from 'history/createBrowserHistory'; 2 | const history = createHistory(); 3 | export default history; 4 | -------------------------------------------------------------------------------- /Chapter06/testing/test-bundler.js: -------------------------------------------------------------------------------- 1 | // needed for regenerator-runtime 2 | // (ES7 generator support is required by redux-saga) 3 | import '@babel/polyfill'; 4 | -------------------------------------------------------------------------------- /Chapter07/app/assets/images/bgheader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Redux-Quick-Start-Guide/HEAD/Chapter07/app/assets/images/bgheader.png -------------------------------------------------------------------------------- /Chapter07/app/components/Header/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Redux-Quick-Start-Guide/HEAD/Chapter07/app/components/Header/logo.png -------------------------------------------------------------------------------- /Chapter07/app/utils/history.js: -------------------------------------------------------------------------------- 1 | import createHistory from 'history/createBrowserHistory'; 2 | const history = createHistory(); 3 | export default history; 4 | -------------------------------------------------------------------------------- /Chapter07/testing/test-bundler.js: -------------------------------------------------------------------------------- 1 | // needed for regenerator-runtime 2 | // (ES7 generator support is required by redux-saga) 3 | import '@babel/polyfill'; 4 | -------------------------------------------------------------------------------- /starter/app/containers/NotFoundPage/Loadable.js: -------------------------------------------------------------------------------- 1 | import loadable from "loadable-components"; 2 | 3 | export default loadable(() => import("./index")); 4 | -------------------------------------------------------------------------------- /starter/app/utils/history.js: -------------------------------------------------------------------------------- 1 | import createHistory from "history/createBrowserHistory"; 2 | const history = createHistory(); 3 | export default history; 4 | -------------------------------------------------------------------------------- /Chapter01/starter/app/containers/HomePage/Loadable.js: -------------------------------------------------------------------------------- 1 | import loadable from 'loadable-components'; 2 | 3 | export default loadable(() => import('./index')); 4 | -------------------------------------------------------------------------------- /Chapter05/app/components/Header/bgheader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Redux-Quick-Start-Guide/HEAD/Chapter05/app/components/Header/bgheader.png -------------------------------------------------------------------------------- /Chapter06/app/components/Header/bgheader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Redux-Quick-Start-Guide/HEAD/Chapter06/app/components/Header/bgheader.png -------------------------------------------------------------------------------- /Chapter07/app/components/Header/bgheader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Redux-Quick-Start-Guide/HEAD/Chapter07/app/components/Header/bgheader.png -------------------------------------------------------------------------------- /Chapter01/starter/app/containers/NotFoundPage/Loadable.js: -------------------------------------------------------------------------------- 1 | import loadable from 'loadable-components'; 2 | 3 | export default loadable(() => import('./index')); 4 | -------------------------------------------------------------------------------- /Chapter01/starter/app/utils/history.js: -------------------------------------------------------------------------------- 1 | import createHistory from 'history/createBrowserHistory'; 2 | const history = createHistory(); 3 | export default history; 4 | -------------------------------------------------------------------------------- /Chapter02/app/Redux/actionCreators.js: -------------------------------------------------------------------------------- 1 | export function addNewDoctor(newDoctorData) { 2 | return { 3 | type: "ADD_NEW_DOCTOR", 4 | newDoctorData 5 | }; 6 | } 7 | -------------------------------------------------------------------------------- /Chapter03/testing/enzyme-setup.js: -------------------------------------------------------------------------------- 1 | import { configure } from "enzyme"; 2 | import Adapter from "enzyme-adapter-react-16"; 3 | 4 | configure({ adapter: new Adapter() }); 5 | -------------------------------------------------------------------------------- /Chapter05/testing/enzyme-setup.js: -------------------------------------------------------------------------------- 1 | import { configure } from "enzyme"; 2 | import Adapter from "enzyme-adapter-react-16"; 3 | 4 | configure({ adapter: new Adapter() }); 5 | -------------------------------------------------------------------------------- /Chapter06/testing/enzyme-setup.js: -------------------------------------------------------------------------------- 1 | import { configure } from 'enzyme'; 2 | import Adapter from 'enzyme-adapter-react-16'; 3 | 4 | configure({ adapter: new Adapter() }); 5 | -------------------------------------------------------------------------------- /Chapter07/testing/enzyme-setup.js: -------------------------------------------------------------------------------- 1 | import { configure } from 'enzyme'; 2 | import Adapter from 'enzyme-adapter-react-16'; 3 | 4 | configure({ adapter: new Adapter() }); 5 | -------------------------------------------------------------------------------- /Chapter03/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": true, 6 | "singleQuote": true, 7 | "trailingComma": "all" 8 | } 9 | -------------------------------------------------------------------------------- /Chapter04/src/reducers/index.js: -------------------------------------------------------------------------------- 1 | import { combineReducers } from "redux"; 2 | 3 | import todos from "./todos"; 4 | 5 | export default combineReducers({ 6 | todos 7 | }); 8 | -------------------------------------------------------------------------------- /Chapter05/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": true, 6 | "singleQuote": true, 7 | "trailingComma": "all" 8 | } 9 | -------------------------------------------------------------------------------- /Chapter06/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": true, 6 | "singleQuote": true, 7 | "trailingComma": "all" 8 | } 9 | -------------------------------------------------------------------------------- /Chapter07/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": true, 6 | "singleQuote": true, 7 | "trailingComma": "all" 8 | } 9 | -------------------------------------------------------------------------------- /Chapter08/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": true, 6 | "singleQuote": true, 7 | "trailingComma": "all" 8 | } 9 | -------------------------------------------------------------------------------- /Chapter06/app/containers/App/actions.js: -------------------------------------------------------------------------------- 1 | import { IS_USER_AUTHENTICATED } from './constants'; 2 | 3 | export const onApplicationLoad = () => ({ type: IS_USER_AUTHENTICATED }); 4 | -------------------------------------------------------------------------------- /Chapter07/app/containers/App/actions.js: -------------------------------------------------------------------------------- 1 | import { IS_USER_AUTHENTICATED } from './constants'; 2 | 3 | export const onApplicationLoad = () => ({ type: IS_USER_AUTHENTICATED }); 4 | -------------------------------------------------------------------------------- /Chapter01/starter/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": true, 6 | "singleQuote": true, 7 | "trailingComma": "all" 8 | } 9 | -------------------------------------------------------------------------------- /Chapter03/.gitignore: -------------------------------------------------------------------------------- 1 | # Don't check auto-generated stuff into git 2 | coverage 3 | build 4 | node_modules 5 | stats.json 6 | 7 | # Cruft 8 | .DS_Store 9 | npm-debug.log 10 | .idea 11 | -------------------------------------------------------------------------------- /Chapter06/app/containers/LocaleToggle/Wrapper.js: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components'; 2 | 3 | const Wrapper = styled.div` 4 | padding: 2px; 5 | `; 6 | 7 | export default Wrapper; 8 | -------------------------------------------------------------------------------- /Chapter07/app/containers/LocaleToggle/Wrapper.js: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components'; 2 | 3 | const Wrapper = styled.div` 4 | padding: 2px; 5 | `; 6 | 7 | export default Wrapper; 8 | -------------------------------------------------------------------------------- /Chapter05/app/components/H1/index.js: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components'; 2 | 3 | const H1 = styled.h1` 4 | font-size: 2em; 5 | margin-bottom: 0.25em; 6 | `; 7 | 8 | export default H1; 9 | -------------------------------------------------------------------------------- /Chapter06/app/components/Toggle/Select.js: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components'; 2 | 3 | const Select = styled.select` 4 | line-height: 1em; 5 | height: 20px; 6 | `; 7 | 8 | export default Select; 9 | -------------------------------------------------------------------------------- /Chapter07/app/components/Toggle/Select.js: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components'; 2 | 3 | const Select = styled.select` 4 | line-height: 1em; 5 | height: 20px; 6 | `; 7 | 8 | export default Select; 9 | -------------------------------------------------------------------------------- /Chapter06/.stylelintrc: -------------------------------------------------------------------------------- 1 | { 2 | "processors": ["stylelint-processor-styled-components"], 3 | "extends": [ 4 | "stylelint-config-recommended", 5 | "stylelint-config-styled-components" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /Chapter07/.stylelintrc: -------------------------------------------------------------------------------- 1 | { 2 | "processors": ["stylelint-processor-styled-components"], 3 | "extends": [ 4 | "stylelint-config-recommended", 5 | "stylelint-config-styled-components" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /Chapter08/.stylelintrc: -------------------------------------------------------------------------------- 1 | { 2 | "processors": ["stylelint-processor-styled-components"], 3 | "extends": [ 4 | "stylelint-config-recommended", 5 | "stylelint-config-styled-components" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /Chapter06/.gitignore: -------------------------------------------------------------------------------- 1 | # Don't check auto-generated stuff into git 2 | coverage 3 | build 4 | node_modules 5 | stats.json 6 | 7 | # Cruft 8 | .DS_Store 9 | npm-debug.log 10 | .idea 11 | .github 12 | .git 13 | -------------------------------------------------------------------------------- /Chapter07/.gitignore: -------------------------------------------------------------------------------- 1 | # Don't check auto-generated stuff into git 2 | coverage 3 | build 4 | node_modules 5 | stats.json 6 | 7 | # Cruft 8 | .DS_Store 9 | npm-debug.log 10 | .idea 11 | .github 12 | .git 13 | -------------------------------------------------------------------------------- /Chapter08/.gitignore: -------------------------------------------------------------------------------- 1 | # Don't check auto-generated stuff into git 2 | coverage 3 | build 4 | node_modules 5 | stats.json 6 | 7 | # Cruft 8 | .DS_Store 9 | npm-debug.log 10 | .idea 11 | .github 12 | .git 13 | -------------------------------------------------------------------------------- /Chapter03/app/containers/Login/__tests__/__snapshots__/index-test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should render correctly 1`] = ` 4 |
15 | `;
16 |
--------------------------------------------------------------------------------
/Chapter01/starter/app/configureStore.js:
--------------------------------------------------------------------------------
1 | import { createStore } from 'redux';
2 |
3 | import createReducer from './reducers';
4 |
5 | export default function configureStore(initialState = {}, history) {
6 | const store = createStore(createReducer());
7 |
8 | // Extensions
9 | store.injectedReducers = {}; // Reducer registry
10 |
11 | return store;
12 | }
13 |
--------------------------------------------------------------------------------
/Chapter03/app/containers/AboutPage/redirect.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Route, Redirect } from "react-router-dom";
3 |
4 | const redirect = () => (
5 |
8 |
9 | # Getting Started
10 |
11 | ## Install dependencies
12 |
13 | ```
14 | yarn install
15 | ```
16 |
17 | ## Start the web
18 |
19 | ```
20 | yarn start
21 | ```
22 |
23 | The web admin should be available at http://localhost:3000/
24 |
--------------------------------------------------------------------------------
/Chapter06/app/components/Footer/tests/__snapshots__/Wrapper.test.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`
8 |
9 | # Getting Started
10 |
11 | ## Install dependencies
12 |
13 | ```
14 | yarn install
15 | ```
16 |
17 | ## Start the web
18 |
19 | ```
20 | yarn start
21 | ```
22 |
23 | The web admin should be available at http://localhost:3000/
24 |
--------------------------------------------------------------------------------
/Chapter07/scripts/helpers/progress.js:
--------------------------------------------------------------------------------
1 | const readline = require('readline');
2 |
3 | function animateProgress(message, amountOfDots) {
4 | if (typeof amountOfDots !== 'number') {
5 | // eslint-disable-next-line
6 | amountOfDots = 3;
7 | }
8 |
9 | let i = 0;
10 | return setInterval(() => {
11 | readline.cursorTo(process.stdout, 0);
12 | i = (i + 1) % (amountOfDots + 1);
13 | const dots = new Array(i + 1).join('.');
14 | process.stdout.write(message + dots);
15 | }, 500);
16 | }
17 |
18 | module.exports = animateProgress;
19 |
--------------------------------------------------------------------------------
/Chapter04/src/actions/todos.js:
--------------------------------------------------------------------------------
1 | import * as types from "../constants/ActionTypes";
2 |
3 | let idCounter = 0;
4 | export const addTodo = text => ({
5 | type: types.ADD_TODO,
6 | text,
7 | id: ++idCounter
8 | });
9 | export const completeTodo = id => ({ type: types.COMPLETE_TODO, id });
10 | export const changeFilter = filter => ({ type: types.CHANGE_FILTER, filter });
11 | export const deleteTodo = id => ({ type: types.DELETE_TODO, id });
12 | export const deleteAllTodos = () => {
13 | idCounter = 0;
14 | return { type: types.DELETE_ALL_TODOS };
15 | };
16 |
--------------------------------------------------------------------------------
/Chapter06/server/middlewares/frontendMiddleware.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable global-require */
2 | module.exports = (app, options) => {
3 | const isProd = process.env.NODE_ENV === 'production';
4 |
5 | if (isProd) {
6 | const addProdMiddlewares = require('./addProdMiddlewares');
7 | addProdMiddlewares(app, options);
8 | } else {
9 | const webpackConfig = require('../../webpack/webpack.dev.babel');
10 | const addDevMiddlewares = require('./addDevMiddlewares');
11 | addDevMiddlewares(app, webpackConfig);
12 | }
13 |
14 | return app;
15 | };
16 |
--------------------------------------------------------------------------------
/Chapter07/server/middlewares/frontendMiddleware.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable global-require */
2 | module.exports = (app, options) => {
3 | const isProd = process.env.NODE_ENV === 'production';
4 |
5 | if (isProd) {
6 | const addProdMiddlewares = require('./addProdMiddlewares');
7 | addProdMiddlewares(app, options);
8 | } else {
9 | const webpackConfig = require('../../webpack/webpack.dev.babel');
10 | const addDevMiddlewares = require('./addDevMiddlewares');
11 | addDevMiddlewares(app, webpackConfig);
12 | }
13 |
14 | return app;
15 | };
16 |
--------------------------------------------------------------------------------
/Chapter06/app/containers/LanguageProvider/reducer.js:
--------------------------------------------------------------------------------
1 | import { fromJS } from 'immutable';
2 |
3 | import { CHANGE_LOCALE } from './constants';
4 | import { DEFAULT_LOCALE } from '../../i18n';
5 |
6 | export const initialState = fromJS({
7 | locale: DEFAULT_LOCALE,
8 | });
9 |
10 | function languageProviderReducer(state = initialState, action) {
11 | switch (action.type) {
12 | case CHANGE_LOCALE:
13 | return state.set('locale', action.locale);
14 | default:
15 | return state;
16 | }
17 | }
18 |
19 | export default languageProviderReducer;
20 |
--------------------------------------------------------------------------------
/Chapter07/app/containers/LanguageProvider/reducer.js:
--------------------------------------------------------------------------------
1 | import { fromJS } from 'immutable';
2 |
3 | import { CHANGE_LOCALE } from './constants';
4 | import { DEFAULT_LOCALE } from '../../i18n';
5 |
6 | export const initialState = fromJS({
7 | locale: DEFAULT_LOCALE,
8 | });
9 |
10 | function languageProviderReducer(state = initialState, action) {
11 | switch (action.type) {
12 | case CHANGE_LOCALE:
13 | return state.set('locale', action.locale);
14 | default:
15 | return state;
16 | }
17 | }
18 |
19 | export default languageProviderReducer;
20 |
--------------------------------------------------------------------------------
/starter/app/configureStore.js:
--------------------------------------------------------------------------------
1 | import { createStore, applyMiddleware, compose } from "redux";
2 |
3 | import createReducer from "./reducers";
4 |
5 | export default function configureStore(initialState = {}, history) {
6 | const store = createStore(
7 | createReducer(),
8 | );
9 |
10 | // Extensions
11 | store.injectedReducers = {}; // Reducer registry
12 |
13 | if (module.hot) {
14 | module.hot.accept("./reducers", () => {
15 | store.replaceReducer(createReducer(store.injectedReducers));
16 | });
17 | }
18 |
19 | return store;
20 | }
21 |
--------------------------------------------------------------------------------
/Chapter05/app/utils/checkStore.js:
--------------------------------------------------------------------------------
1 | import { conformsTo, isFunction, isObject } from 'lodash';
2 | import invariant from 'invariant';
3 |
4 | export default function checkStore(store) {
5 | const shape = {
6 | dispatch: isFunction,
7 | subscribe: isFunction,
8 | getState: isFunction,
9 | replaceReducer: isFunction,
10 | runSaga: isFunction,
11 | injectedReducers: isObject,
12 | injectedSagas: isObject,
13 | };
14 | invariant(
15 | conformsTo(store, shape),
16 | '(app/utils...) injectors: Expected a valid redux store',
17 | );
18 | }
19 |
--------------------------------------------------------------------------------
/Chapter06/app/utils/checkStore.js:
--------------------------------------------------------------------------------
1 | import { conformsTo, isFunction, isObject } from 'lodash';
2 | import invariant from 'invariant';
3 |
4 | export default function checkStore(store) {
5 | const shape = {
6 | dispatch: isFunction,
7 | subscribe: isFunction,
8 | getState: isFunction,
9 | replaceReducer: isFunction,
10 | runSaga: isFunction,
11 | injectedReducers: isObject,
12 | injectedSagas: isObject,
13 | };
14 | invariant(
15 | conformsTo(store, shape),
16 | '(app/utils...) injectors: Expected a valid redux store',
17 | );
18 | }
19 |
--------------------------------------------------------------------------------
/Chapter07/app/utils/checkStore.js:
--------------------------------------------------------------------------------
1 | import { conformsTo, isFunction, isObject } from 'lodash';
2 | import invariant from 'invariant';
3 |
4 | export default function checkStore(store) {
5 | const shape = {
6 | dispatch: isFunction,
7 | subscribe: isFunction,
8 | getState: isFunction,
9 | replaceReducer: isFunction,
10 | runSaga: isFunction,
11 | injectedReducers: isObject,
12 | injectedSagas: isObject,
13 | };
14 | invariant(
15 | conformsTo(store, shape),
16 | '(app/utils...) injectors: Expected a valid redux store',
17 | );
18 | }
19 |
--------------------------------------------------------------------------------
/Chapter06/server/middlewares/addProdMiddlewares.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const express = require('express');
3 | const compression = require('compression');
4 |
5 | module.exports = function addProdMiddlewares(app, options) {
6 | const publicPath = options.publicPath || '/';
7 | const outputPath = options.outputPath || path.resolve(process.cwd(), 'build');
8 |
9 | app.use(compression());
10 | app.use(publicPath, express.static(outputPath));
11 |
12 | app.get('*', (req, res) =>
13 | res.sendFile(path.resolve(outputPath, 'index.html')),
14 | );
15 | };
16 |
--------------------------------------------------------------------------------
/Chapter07/server/middlewares/addProdMiddlewares.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const express = require('express');
3 | const compression = require('compression');
4 |
5 | module.exports = function addProdMiddlewares(app, options) {
6 | const publicPath = options.publicPath || '/';
7 | const outputPath = options.outputPath || path.resolve(process.cwd(), 'build');
8 |
9 | app.use(compression());
10 | app.use(publicPath, express.static(outputPath));
11 |
12 | app.get('*', (req, res) =>
13 | res.sendFile(path.resolve(outputPath, 'index.html')),
14 | );
15 | };
16 |
--------------------------------------------------------------------------------
/Chapter06/app/components/ToggleOption/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * ToggleOption
4 | *
5 | */
6 |
7 | import React from 'react';
8 | import PropTypes from 'prop-types';
9 | import { injectIntl, intlShape } from 'react-intl';
10 |
11 | const ToggleOption = ({ value, message, intl }) => (
12 |
13 | );
14 |
15 | ToggleOption.propTypes = {
16 | value: PropTypes.string.isRequired,
17 | message: PropTypes.object,
18 | intl: intlShape.isRequired,
19 | };
20 |
21 | export default injectIntl(ToggleOption);
22 |
--------------------------------------------------------------------------------
/Chapter07/app/components/ToggleOption/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * ToggleOption
4 | *
5 | */
6 |
7 | import React from 'react';
8 | import PropTypes from 'prop-types';
9 | import { injectIntl, intlShape } from 'react-intl';
10 |
11 | const ToggleOption = ({ value, message, intl }) => (
12 |
13 | );
14 |
15 | ToggleOption.propTypes = {
16 | value: PropTypes.string.isRequired,
17 | message: PropTypes.object,
18 | intl: intlShape.isRequired,
19 | };
20 |
21 | export default injectIntl(ToggleOption);
22 |
--------------------------------------------------------------------------------
/Chapter02/app/React/__tests__/EmailInput-test.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import renderer from "react-test-renderer";
3 |
4 | import EmailInput from "../EmailInput";
5 |
6 | it("should render correctly", () => {
7 | const component = renderer.create(