Code React Sweetly
Code React Sweetly
A Beginner-Friendly Guide to Build and Deploy Modern Apps with React
About the Book
Code React Sweetly is your complete, beginner-friendly guide to learning React—the world’s most popular JavaScript library for building modern, interactive user interfaces.
Whether you’re starting your first coding project or looking to sharpen your skills as a front-end or full-stack developer, this book gives you everything you need to confidently build, style, and deploy professional-grade React applications.
Why You’ll Love This Book
- Learn React the Right Way: Understand React fundamentals without getting lost in frameworks like Next.js. You’ll master JSX, components, props, state, refs, forms, styling, and more—step by step.
- Hands-On and Project-Driven: No fluff. Each chapter includes examples and projects that reinforce your skills.
- Master React Hooks: Gain confidence with React’s most powerful features, including useState, useEffect, and useRef, and learn when to use state, refs, and variables.
- Deploy with Confidence: Learn how to take your React app live and share your creations with the world.
- Avoid Tutorial Hell: Stop passively watching videos. This book gets you coding immediately so you can actually build and ship projects.
What You’ll Learn
Inside, you’ll:
- Understand what React is, why it exists, and how it works
- Use JSX to create clean and readable UIs
- Build reusable components and pass data with props
- Render lists and dynamic content using arrays and `.map()`
- Handle events and user interactions
- Manage component state with the `useState` hook
- Control side effects with useEffect
- Work with references, states, and variables effectively
- Build different types of forms
- Style components with CSS, inline styles, and CSS-in-JS
- Add multi-page functionality with React Router
- Deploy your React app to the web for real-world use
Who This Book Is For
- Beginners who know JavaScript, HTML, and CSS basics but are new to React
- Developers who have struggled with scattered tutorials and want a structured, practical guide
- Anyone ready to escape tutorial hell and start shipping real projects
Why Buy This Book?
By the end, you won’t just “know” React—you’ll be a React developer with the tools, confidence, and portfolio-ready project to stand out as a front-end or full-stack developer.
If you’re ready to learn React in a way that’s clear, practical, and immediately useful, this is the book for you.
Buy your copy today and start building the React apps you’ve always wanted!
Table of Contents
- Introduction
- Welcome to Code React Sweetly!
- Why This Book Is Different
- The Roadmap
- The Tools
- What You Should Already Know
- A Personal Note
- Let’s Begin!
- Getting Started with React
- Why the “React” Name?
- Is React a Framework?
- Is React Only for Web Development?
- What’s the Primary Goal of React?
- Adding React Component to a Website
- Why Use HTML Inside JavaScript?
- JSX
- Can React Work Without JSX?
- What Is React.createElement()?
- How to Use JSX
- Time to Practice with JSX
- Components
- What Exactly Are Props in React?
- How to Invoke React Components
- How to Display a Component Inside a Browser’s DOM Node
- Important Things to Know About React Components
- Creating Reusable React Components
- Time to Practice with Components
- Rendering Lists of Elements from an Array
- Each React Element in an Array Needs a Unique Key
- How to Add Unique Keys to Each React Element in an Array
- Important Things to Know About Assigning Keys
- Event Handling in React
- Types of Event Handlers
- What Is an Inline Event Handler in React?
- What Is a Referenced Event Handler in React?
- HTML vs. React Events: What’s the Difference?
- How to Use Arguments with a Component’s Event Handler
- How to Access an Event Object in React
- React State
- How to Access and Modify a Function Component’s State
- What Exactly Is the useState() Function?
- Why Does useState() Return an Array?
- How to Update a Component’s State
- How to Reset a Component’s States
- Important Things to Know About React State
- Time to Practice with React State
- How Did You Go About Creating Your Login (out) Button?
- How Does the React State Hook Work Behind the Scenes?
- React Trigger vs. Render vs. Commit vs. Paint
- Triggering a Render in React
- Rendering React Components
- Committing React UI to the Browser’s DOM
- Painting the DOM Nodes on the Screen
- Effect Hooks
- Types of Effects in React
- How to Know the Effects That Require Cleanup
- How to Know the Effects That Do Not Require Any Cleanup
- How to Clean Up a Component’s Effects
- How to Specify When React Effects Should Run
- Important Things to Know About the Effect Hook in React
- Ref Hook
- How to Access a Function Component’s Ref
- What Exactly Is the useRef() Function?
- How to Access the Value Inside a Ref Object
- How to Update the Value Inside a Ref Object
- Important Things to Know About Accessing and Updating React Refs
- How to Use React Refs to Manage DOM Nodes
- How Does React Ref Hook Work Behind the Scenes?
- How Does Updating
ref.current
Affect the Ref Hook’s State Object?
- Variables vs. Refs vs. States
- How Do Variables Work in React?
- How Do Refs Work in React?
- How Do States Work in React?
- Tips on Using Variables, Refs, and States in React
- Forms in React
- Types of Fields in React Forms
- What Is a Controlled Component in React?
- What Is an Uncontrolled Component in React?
- Important Things to Know About Forms in React
- Time to Practice with React Forms
- How Did You Go About Creating Your Form App?
- Styling in React
- Using CSS Style Sheets to Style React Elements
- Using the Inline
style
Attribute to Style React Elements
- Using CSS Modules to Style React Elements
- Using a CSS-in-JS Library to Style React Elements
- Deploying React Apps
- 1. Configure a GitHub Remote Repository
- 2. Stage and Commit Any Recent Changes
- 3. Upload Your Local Git Directory to the Remote Repo
- 4. Sign In or Sign Up on the Vercel Website
- 5. Deploy Your Project to Vercel’s Server
- 6. View Your Published App
- Building React Applications with Multi-Page Functionality
- Single-page vs. multi-page applications: What’s the difference?
- What exactly is React Router?
- 1. Set up your system
- 2. Create a new project directory
- 3. Create a package.json File
- 4. Install React and ReactDOM
- 5. Create the web page
- 6. Create a components directory
- 7. Create an App component
- 8. Create the entry script
- 9. Create an About component
- 10. Install React Router
- 11. Create an AppRoutes component
- 12. How to handle unavailable URL requests in ReactJS
- 13. Render
as the app’s root component
- 14. Run your application
- How to serve static files
- How to Deploy a multi-page React application
- Time to practice with building a multi-page-like React application️️️️
- Epilogue
- What Next?
- Keep Growing
- One Last Favor
- Final Words
- Introduction
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $14 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them