List of Listings

Chapter 2. Your first Redux application

Listing 2.1. An outline of the Redux store

Listing 2.2. src/components/Task.js

Listing 2.3. src/components/TaskList.js

Listing 2.4. src/components/TasksPage.js

Listing 2.5. src/App.js

Listing 2.6. The store API in action

Listing 2.7. src/index.js

Listing 2.8. src/reducers/index.js

Listing 2.9. src/reducers/index.js

Listing 2.10. src/index.js

Listing 2.11. src/App.js: connecting components

Listing 2.12. Adding the New Task form

Listing 2.13. Logging this.props in src/App.js

Listing 2.14. src/App.js: adding an action handler

Listing 2.15. src/actions/index.js: the createTask action creator

Listing 2.16. src/reducers/index.js

Listing 2.17. src/App.js

Listing 2.18. src/reducers/index.js

Listing 2.19. src/reducers/index.js

Listing 2.20. src/components/Task.js

Listing 2.21. src/actions/index.js

Listing 2.22. src/App.js

Listing 2.23. src/components/TasksPage.js

Listing 2.24. src/components/TaskList.js

Listing 2.25. src/components/Task.js

Listing 2.26. src/reducers/index.js

Chapter 3. Debugging Redux applications

Listing 3.1. src/index.js

Listing 3.2. src/index.js

Listing 3.3. src/index.js

Chapter 4. Consuming an API

Listing 4.1. src/reducers/index.js

Listing 4.2. src/App.js

Listing 4.3. src/actions/index.js

Listing 4.4. src/api/index.js

Listing 4.5. src/actions/index.js

Listing 4.6. src/reducers/index.js

Listing 4.7. src/api/index.js

Listing 4.8. src/actions/index.js

Listing 4.9. src/reducers/index.js

Listing 4.10. src/api/index.js

Listing 4.11. src/actions/index.js

Listing 4.12. src/reducers/index.js

Listing 4.13. src/reducers/index.js

Listing 4.14. index.js

Listing 4.15. src/actions/index.js

Listing 4.16. src/reducers/index.js

Listing 4.17. src/App.js

Listing 4.18. src/components/TasksPage.js

Listing 4.19. src/components/FlashMessage.js

Listing 4.20. src/App.js

Listing 4.21. src/actions/index.js

Listing 4.22. src/reducers/index.js

Chapter 5. Middleware

Listing 5.1. Creating the logger middleware – src/middleware/logger.js

Listing 5.2. Adding the logger middleware to the store – src/index.js

Listing 5.3. Adding the meta property – src/actions/index.js

Listing 5.4. Implementing the analytics middleware – src/middleware/index.js

Listing 5.5. Applying the analytics middleware – src/index.js

Listing 5.6. Redirecting after login

Listing 5.7. Routing logic in a middleware

Listing 5.8. Updating fetchTasks – src/actions/index.js

Listing 5.9. Sketching out the API middleware – src/middleware/api.js

Listing 5.10. Registering the API middleware – src/index.js

Listing 5.11. Dispatching the request started action – src/middleware/api.js

Listing 5.12. The makeCall function – src/middleware/api.js

Listing 5.13. Making the AJAX call – src/middleware/api.js

Listing 5.14. Updating the tasks reducer – src/reducers/index.js

Listing 5.15. Updating the API middleware – src/middleware/api.js

Listing 5.16. Implementing the new createTasks – src/actions/index.js

Listing 5.17. Updating the tasks reducer – src/reducers/index.js

Chapter 6. Handling complex side effects

Listing 6.1. src/actions/index.js

Listing 6.2. Basic generator example

Listing 6.3. Iteration with a generator example

Listing 6.4. Infinite loop example

Listing 6.5. Composing generators example

Listing 6.6. src/index.js

Listing 6.7. src/sagas.js

Listing 6.8. src/sagas.js

Listing 6.9. src/sagas.js

Listing 6.10. src/sagas.js

Listing 6.11. src/actions/index.js

Listing 6.12. src/sagas.js

Listing 6.13. db.json

Listing 6.14. src/actions/index.js

Listing 6.15. src/sagas.js

Listing 6.16. src/reducers/index.js

Listing 6.17. src/sagas.js

Listing 6.18. src/actions/index.js

Listing 6.19. src/sagas.js

Listing 6.20. An async/await example

Chapter 7. Preparing data for components

Listing 7.1. mapStateToProps - src/App.js

Listing 7.2. filteredTasks persisted in Redux

Listing 7.3. Adding the search input – src/components/TasksPage.js

Listing 7.4. Adding styles – src/index.css

Listing 7.5. Search with local component state – src/components/TasksPage.js

Listing 7.6. Adding onSearch to App – src/App.js

Listing 7.7. Using the onSearch prop – src/components/TasksPage.js

Listing 7.8. Adding a new action creator – src/actions/index.js

Listing 7.9. Adding update logic to the tasks reducer – src/reducers/index.js

Listing 7.10. Applying the filter in mapStateToProps – src/App.js

Listing 7.11. Moving filter logic into the tasks reducer – src/reducers/index.js

Listing 7.12. Importing and using the selector – src/App.js

Listing 7.13. Exploring memoization

Listing 7.14. Adding memoization to double

Listing 7.15. Updating mapStateToProps – src/App.js

Listing 7.16. Creating new selectors – src/reducers/index.js

Listing 7.17. Grouping tasks by status – src/components/TaskPage.js

Listing 7.18. Grouped tasks

Listing 7.19. Updating task rendering – src/components/TasksPage.js

Listing 7.20. Create a new constants module – src/constants/index.js

Listing 7.21. Creating the new selector – src/reducers/index.js

Listing 7.22. Importing and using the new selector – src/App.js

Chapter 8. Structuring a Redux store

Listing 8.1. Example API response

Listing 8.2. An example Redux store with projects and tasks

Listing 8.3. Adding a user to each task

Listing 8.4. A normalized Redux store

Listing 8.5. The Redux store’s structure using nested data

Listing 8.6. An example API response

Listing 8.7. Updating db.json

Listing 8.8. Importing and dispatching fetchProjects – src/App.js

Listing 8.9. Updating the API client – src/api/index.js

Listing 8.10. Creating fetchProjects – src/actions/index.js

Listing 8.11. Updating the tasks reducer – src/reducers/index.js

Listing 8.12. Handling new actions in the projects reducer – src/reducers/index.js

Listing 8.13. Adding the page reducer – src/reducers/index.js

Listing 8.14. Update createStore – src/index.js

Listing 8.15. Connecting projects to React – src/App.js

Listing 8.16. Updating selectors to handle projects – src/reducers/index.js

Listing 8.17. The Header component – src/components/Header.js

Listing 8.18. Rendering Header – src/App.js

Listing 8.19. Adding setCurrentProjectId – src/actions/index.js

Listing 8.20. Existing code for CREATE_TASK_SUCCEEDED – src/reducers/index.js

Listing 8.21. Updating the projects reducer – src/reducers/index.js

Listing 8.22. Existing EDIT_TASKS_SUCCEEDED code – src/reducers/index.js

Listing 8.23. Finding the project -- src/reducers/index.js

Listing 8.24. Why objects with IDs make lookups easier

Listing 8.25. Adding normalizr schemas – src/actions/index.js

Listing 8.26. Normalizing the response – src/actions/index.js

Listing 8.27. Creating the tasks reducer and RECEIVE_ENTITIES – src/reducers/index.js

Listing 8.28. Using the tasks reducer – src/index.js

Listing 8.29. Updating App – src/App.js

Listing 8.30. Updating selectors – src/reducers/index.js

Listing 8.31. Handling CREATE_TASK_SUCCEEDED – src/reducers/index.js

Listing 8.32. Updating normalized tasks – src/reducers/index.js

Listing 8.33. Refactoring the tasks reducer – src/reducers/index.js

Chapter 9. Testing Redux applications

Listing 9.1. The package.json file after ejecting from Create React App

Listing 9.2. Example Jasmine test

Listing 9.3. Example synchronous action

Listing 9.4. Synchronous action creator test

Listing 9.5. The createTask async action creator

Listing 9.6. Configuring a mock Redux store

Listing 9.7. Mocking api.createTask

Listing 9.8. Testing createTask

Listing 9.9. The handleProgressTimer saga

Listing 9.10. Testing sagas

Listing 9.11. exampleMiddleware – Analytics middleware

Listing 9.12. exampleService.js – Example fake analytics API service

Listing 9.13. Analytics middleware test

Listing 9.14. Tasks reducer

Listing 9.15. Tasks reducer test

Listing 9.16. Example selectors

Listing 9.17. Testing selectors

Listing 9.18. Example presentational component

Listing 9.19. Presentational component tests

Listing 9.20. Example snapshot tests

Listing 9.21. Example container component

Listing 9.22. A container test attempt

Listing 9.23. Example container test

Listing 9.24. Container test with a mock store

Listing 9.25. The editTask action creator

Listing 9.26. Testing the editTask action creator

Chapter 10. Performance

Listing 10.1. shouldComponentUpdate example

Listing 10.2. Log renders in TasksPage – src/components/TasksPage.js

Listing 10.3. Log renders in Header – src/components/Header.js

Listing 10.4. Refactoring header/tasks code out of App – src/App.js

Listing 10.5. Adding connect to Header – src/components/Header.js

Listing 10.6. Adding connect to TasksPage – src/components/TasksPage.js

Listing 10.7. getProjects selector - src/reducers/index.js

Listing 10.8. Making getProjects a memoized selector – src/reducers/index.js

Listing 10.9. fetchProjects action – src/actions/index.js

Listing 10.10. Configuration for batching actions – src/index.js

Listing 10.11. Batching fetchProjects dispatches – src/actions/index.js

Listing 10.12. Logging Task renders – src/components/Task.js

Listing 10.13. Connecting the Task component – src/components/Task.js

Listing 10.14. Updating TaskList – src/components/TaskList.js

Listing 10.15. Updating TasksPage – src/components/TasksPage.js

Listing 10.16. Adding the new selector – src/reducers/index.js

Chapter 11. Structuring Redux code

Listing 11.1. An example ducks file

Appendix Installation

Listing 1. db.json

Listing 2. src/index.js

Listing 3. src/index.js

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.64.243