Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
React 16 Tooling

You're reading from  React 16 Tooling

Product type Book
Published in Apr 2018
Publisher Packt
ISBN-13 9781788835015
Pages 298 pages
Edition 1st Edition
Languages
Authors (2):
Adam Boduch Adam Boduch
Profile icon Adam Boduch
Christopher Pitt Christopher Pitt
Profile icon Christopher Pitt
View More author details

Table of Contents (18) Chapters

Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
1. Creating a Personalized React Development Ecosystem 2. Efficiently Bootstrapping React Applications with Create React App 3. Development Mode and Mastering Hot Reloading 4. Optimizing Test-Driven React Development 5. Streamlining Development and Refactoring with Type-Safe React Components 6. Enforcing Code Quality to Improve Maintainability 7. Isolating Components with Storybook 8. Debugging Components in the Browser 9. Instrumenting Application State with Redux 10. Building and Deploying Static React Sites with Gatsby 11. Building and Deploying React Applications with Docker Containers 1. Another Book You May Enjoy Index

Chapter 3. Development Mode and Mastering Hot Reloading

In the previous chapter, you learned how to use create-react-app. This is just the beginning of our React tooling journey. By using create-react-app to bootstrap your application, you're installing many other tools used for development. These tools are part of the react-scripts package. The focus of this chapter will be the development server that comes with react-scripts where we'll cover:

  • Starting the development server
  • Automatic Webpack configuration
  • Putting hot component reloading to use

Starting the development server


If you created a React application using the create-react-app tool in the previous chapter, then you have everything you need to launch a development server. No configuration is necessary! Let's start it up right now. First, make sure that you're in the project directory:

cd my-react-app/

Now you can start the development server:

npm start

This will start the development server using the start script from the react-scripts package. You should see the console output that looks like this:

Compiled successfully!You can now view my-react-app in the browser.Local:            http://localhost:3000/On Your Network:  http://192.168.86.101:3000/Note that the development build is not optimized.To create a production build, use npm run build.

You'll notice that in addition to printing this output in the console, this script will launch a new browser tab with http://localhost:3000/ as the address. The page that's displayed looks like this:

We've accomplished a lot in just a...

Summary


In this chapter, you learned how to start the development server for a project created with create-react-app. You then learned that the react-scripts package has its own Webpack configuration that it uses when it starts the development server for you. We went over the key areas of configuration that you shouldn't necessarily have to think about when you're trying to write an application.

Finally, you saw hot module reloading in action. Out of the box, react-scripts reloads the app for you when you make source changes. This results in a page refresh, which is good enough to get started. We then looked at the potential challenges of developing components using this approach because it wipes out any state that the component had before it was updated. So you ejected from create-react-app and customized the Webpack configuration for your project to support hot component reloading that will preserve the state.

In the following chapter, you'll work with tooling to support unit tests in your...

lock icon The rest of the chapter is locked
You have been reading a chapter from
React 16 Tooling
Published in: Apr 2018 Publisher: Packt ISBN-13: 9781788835015
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime}