Chapter 1: Why MERN
This is an introductory chapter that discusses the history of React and MERN and why it's suitable for a variety of web apps. One interesting topic that I will be discussing here is why it was created and what problem it tried to solve. This will give great insights into what kind of apps React is most suitable for, and for what kind of apps it will be a misfit.
Chapter 2: Intro to React and Hello World
This chapter starts with installation of some basic components: Node, npm, Express, Babel and React. Then, the first pieces of code is written, which brings up the customary Hello World app. All the code at this point is in React (ie, no server side coding). I introduce the basics of React in this chapter.
Chapter 3: React Components
Here, I'll invent the functional requirements of our sample app that we'll use throughout the book. Then, I'll start off the first important concept of React: components and composition. Using this, we'll build the first cut of the sample app - we'll build the UI to show a list of bugs, a placeholder for a filter to control the list and another placeholder which will become a form to add a bug to the list.
Chapter 4: Data from Server
In this chapter, I will describe how data can be served from the server via APIs. I'll introduce Express and describe how to create REST APIs using Express routes. At the end of this chapter, we'll be serving the data from the server instead of hardcoded data on in our app scripts, and using this data to render our components.
Chapter 5: Using MongoDB to save the data
Here, we'll take data handling to the next level and introduce MongoDB. We'll explore how to save and retrieve data from a MongoDB database via the Mongo shell, and later, via the MongoDB Driver from our app server.
Chapter 6: Build and Bundle using Webpack
When we have many components, it is good to modularize the app. It also becomes essential when we start using third party libraries. In this chapter, I show how the app can be split into modules. To manage the dependencies and create a single bundle containing all the front-end code, we will use a utility called webpack. At the end of this chapter, we have a complete stack and the required development tools all in place. Further chapters will improve our sample app by adding more features, which require other libraries and/or features of each component of the MERN stack.
Chapter 7: Dynamic Components and Interactivity
We'll take Components to the next level in this chapter. I'll cover how to dynamically update components by manipulating state, how to deal with user interaction and finally how to communicate between components. At the end of this chapter, the user will be able to add a record to the list using a form.
Chapter 8: Routing using React Router
Routing is the act of switching between sections of the app using a URL that indicates where we are. In a single page app (SPA) a new URL does not translate to a full page request to the server, the DOM is updated by making lightweight ajax calls. React by itself does not mandate any particular routing mechanism, but fortunately there are other libraries that simplify routing for us. In this chapter, we'll introduce React Router and use that to route between different views in the app.
Chapter 9: Forms and Component Lifecycle
Handling user input via forms the React is a little different from the conventional Javascript / jQuery way. In this chapter we'll explore how user input is captured. We'll explore controlled components and uncontrolled components and which is one is appropriate in which situation. We'll now have proper forms acting as input to adding a new bug, editing an existing one, and setting a new filter.
Chapter 10: Using React Bootstrap
React Bootstrap is an epitome of how to build reusable React components. By using some existing Bootstrap components to give a polished look to our UI, we'll also learn how to build good re-usable components.
Chapter 11: Redux
The Flux architecture simplifies state handling by encapsulating all the state in what's called a Store. Instead of multiple states within each component, the Flux architectural pattern helps us think in terms of a global state. There are many implementations of Flux, we'll choose the Redux implementation and refactor the app.
Chapter 12: Session handling
Any web app will need some authentication and perhaps authorization. In this chapter, I'll introduce sessions in Express, and how to connect a session to say, a Google Authentication sign-on. Now, our app will be protected by only those who we can give access. We'll also be able to restrict who can do what kind of operations in the app.
Chapter 13: Server side rendering
A React based app is not complete till we take advantage of server side rendering. This lets us render entire pages when required, especially for automated search engine bots such as the Google-bot. At the same time, we keep our human users happy by behaving as a single-page app when requests come from a browser.
Chapter 14: Concluding remarks and mern-cli
We'll wrap up and re-cap the important concepts of the previous chapters. This is also an opportunity to introduce mern-cli, a quick way to scaffold and start off a new project.