49 | Josh Claunch - someone we repeatedly go to for feedback/advice on things I'm writing, and for having very advanced knowledge of state management in React applications
50 |
51 |
52 | Anthony Conklin - someone else we can always rely on for fresh feedback
53 |
54 |
55 | Theo-Flux for being the first person to contribute to the project besides myself, giving us hope that we're working on something worthwhile
56 |
57 |
58 |
59 | Tono Nogueras{' '}
60 | {' '}
61 | for significant contributions to the React Native guide
62 |
63 |
64 |
65 |
66 |
67 |
68 | Join 10+ other{' '}
69 |
70 | contributors
71 |
72 | , and help us maintain the website as an example of what a solid Next.js
73 | application codebase can look like.
74 |
139 | Static websites, SEO-friendly rendering, Fast dynamic apps/sites,
140 | SPAish Support (via export)
141 |
142 |
143 | SEO-friendly rendering, Fast dynamic apps/sites, Deploying
144 | "to the edge"
145 |
146 |
147 |
148 |
149 |
Learning Resources
150 |
151 |
152 |
153 |
154 | Gatsby Tutorial
155 |
156 |
157 |
158 |
159 | Getting Started With Gatsby
160 |
161 |
162 |
163 |
164 | Build a Blog with Markdown & Gatsby
165 |
166 |
167 |
168 |
169 |
170 |
171 | Next.js Tutorial
172 |
173 |
174 |
175 |
176 | Introduction to Next.js by Xiaoru Li
177 |
178 |
179 |
180 |
181 |
182 |
183 | Remix Tutorial
184 |
185 |
186 |
187 |
188 | Up & Running With Remix by Kent C. Dodds
189 |
190 |
191 |
192 |
193 | Remix Tutorial with Kent C. Dodds
194 |
195 |
196 |
197 |
198 |
199 |
200 |
Things To Be Aware Of
201 |
202 |
Mostly for SSG only.
203 |
204 | Next.js strongly encourages a Node.js runtime to
205 | serve/run the app (not required if you do a static export). Gatsby
206 | and Remix do not.
207 |
208 |
209 |
210 | Remix generally encourages you to move a lot of typical
211 | client-side "state" to the edge/server, sometimes
212 | removing the need to manage a "state" in the frontend
213 | altogether.
214 |
215 |
216 | Remix generally encourages you to fetch data for your
217 | apps/components from the edge/server via "loader
218 | functions".
219 |
220 |
221 | While the router / nested routes bring a big performance boost
222 | to your app, there's also a bit of a learning curve. This
223 | is a moot point if you're also considering the App Router
224 | in Next.js, as that also comes with a learning curve.
225 |
226 |
227 | Remix doesn't support SSG (which in a lot of cases is
228 | probably fine if your goals are simply to deliver a fast user
229 | experience).
230 |
16 |
17 |
18 |
19 | bulletproof-react
20 |
21 |
22 | simple
23 |
24 |
25 | scale-up
26 |
27 |
28 |
29 | This directory structure is based on the{' '}
30 |
31 | bulletproof-react
32 | {' '}
33 | repo - it is an absolute goldmine for good practices and architecture
34 | of large/enterprise React application.
35 |
36 |
37 |
38 | This structure comes directly from{' '}
39 |
40 | Josh Comeau
41 | {' '}
42 | - a very talented author of educational material in the webdev
43 | community. Read more of his React articles{' '}
44 |
45 | here
46 |
47 | .
48 |
49 |
50 |
51 | This structure can be used for medium to large React applications, adapted from{' '}
52 |
53 | Robin Wieruch
54 | {' '}
55 | - a high quality educator and content creator for in-depth tutorials and articles. Visit his blog{' '}
56 |
57 | here
58 |
59 | .
60 |
61 |
62 |
63 |
19 | )
20 | }
21 |
22 | export function GreenfieldContent() {
23 | return (
24 |
25 |
26 | 1. Start by lifting state where possible
27 |
28 |
29 |
30 | Choose a State Structure
31 | {' '}
32 | for the data you'll manage
33 |
34 |
35 | Lift state{' '}
36 |
37 | to a parent
38 |
39 |
40 |
41 | Lift state to{' '}
42 |
43 | avoid prop-drilling
44 |
45 |
46 |
47 | Lift state to{' '}
48 |
49 | communicate with sibling components
50 |
51 |
52 |
53 |
54 | Co-locate
55 | {' '}
56 | state near where it is used
57 |
58 |
59 |
60 |
61 | 2. Need More Functionality?
62 |
63 |
64 | For Data-Fetching{' '}
65 | choose one of the following
66 |
67 |
68 |
69 | tanstack-query
70 | {' '}
71 | (REST APIs)
72 |
73 |
74 |
75 | apollo-client
76 | {' '}
77 | (GraphQL)
78 |
79 |
80 |
81 |
82 | For{' '}
83 |
84 | Global Stores
85 | {' '}
86 | choose one of the following
87 |
88 |
89 |
90 | Zustand
91 | {' '}
92 | (FLUX)
93 |
94 |
95 |
96 | Jotai
97 | {' '}
98 | (Atomic)
99 |
100 |
101 |
102 |
103 | For extremely complex state, consider state machines like{' '}
104 |
105 | xState (or the simpler @xState/xStore)
106 |
107 |
108 |
109 |
110 |
111 | )
112 | }
113 |
114 | export function ReduxContent() {
115 | return (
116 |
117 |
118 | Redux to the Rescue
119 |
120 |
121 |
122 | Redux Toolkit (RTK)
123 | {' '}
124 | is the modern way to write with Redux
125 |
126 |
127 | Includes a mechanism for{' '}
128 |
129 | Data-Fetching
130 |
131 |
132 |
133 | Includes common{' '}
134 |
135 | middleware
136 | {' '}
137 | out of the box
138 |
139 | Can provide consistency to large projects/teams
140 |
141 |
142 |
143 | )
144 | }
145 |
146 | export function RecommendationContent() {
147 | return (
148 | <>
149 |
150 | Starting Points for State Management
151 |
152 |
153 |
154 | Data-Fetching
155 | Store
156 |
157 |
158 |
159 |
160 | tanstack-query
161 | {' '}
162 | (REST APIs)
163 |
164 |
165 |
166 | Zustand
167 | {' '}
168 | or{' '}
169 | Jotai{' '}
170 | or{' '}
171 | MobX
172 |
173 |
174 |
175 |
176 | swr{' '}
177 | (REST APIs)
178 |
179 |
180 |
181 | Zustand
182 | {' '}
183 | or{' '}
184 | Jotai{' '}
185 | or{' '}
186 | MobX
187 |
188 |
189 |
190 |
191 |
192 | apollo-client
193 | {' '}
194 | (GraphQL)
195 |
196 |
197 |
198 | Zustand
199 | {' '}
200 | or{' '}
201 | Jotai{' '}
202 | or{' '}
203 | MobX
204 |
205 |
206 |
207 |
208 |
209 | RTK-Query
210 | {' '}
211 |
212 |
213 |
214 | Redux (RTK)
215 |
216 |
217 |
218 |
219 | >
220 | )
221 | }
222 |
--------------------------------------------------------------------------------
/src/images/logos/go.svg:
--------------------------------------------------------------------------------
1 |
15 |
--------------------------------------------------------------------------------
/src/images/logos/handbook.svg:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/src/images/logos/node.svg:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/src/images/logos/php.svg:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/src/images/logos/python.svg:
--------------------------------------------------------------------------------
1 |
14 |
--------------------------------------------------------------------------------
/src/images/logos/ruby.svg:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/src/lib/remToPx.js:
--------------------------------------------------------------------------------
1 | export function remToPx(remValue) {
2 | let rootFontSize =
3 | typeof window === 'undefined'
4 | ? 16
5 | : parseFloat(window.getComputedStyle(document.documentElement).fontSize)
6 |
7 | return parseFloat(remValue) * rootFontSize
8 | }
9 |
--------------------------------------------------------------------------------
/src/pages/_app.jsx:
--------------------------------------------------------------------------------
1 | import Head from 'next/head'
2 | import { Router, useRouter } from 'next/router'
3 | import { MDXProvider } from '@mdx-js/react'
4 | import { Analytics } from '@vercel/analytics/react'
5 |
6 | import { Layout } from '@/components/Layout'
7 | import * as mdxComponents from '@/components/mdx'
8 | import { useMobileNavigationStore } from '@/components/MobileNavigation'
9 |
10 | import '@/styles/tailwind.css'
11 | import 'focus-visible'
12 |
13 | function onRouteChange() {
14 | useMobileNavigationStore.getState().close()
15 | }
16 |
17 | Router.events.on('hashChangeStart', onRouteChange)
18 | Router.events.on('routeChangeComplete', onRouteChange)
19 | Router.events.on('routeChangeError', onRouteChange)
20 |
21 | export default function App({ Component, pageProps }) {
22 | let router = useRouter()
23 |
24 | return (
25 | <>
26 |
27 | {router.pathname === '/' ? (
28 | React Handbook
29 | ) : (
30 | {`${pageProps.title} - React Handbook`}
31 | )}
32 |
33 |
38 |
44 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | >
59 | )
60 | }
61 |
--------------------------------------------------------------------------------
/src/pages/_document.jsx:
--------------------------------------------------------------------------------
1 | import { Head, Html, Main, NextScript } from 'next/document'
2 |
3 | const modeScript = `
4 | let darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)')
5 |
6 | updateMode()
7 | darkModeMediaQuery.addEventListener('change', updateModeWithoutTransitions)
8 | window.addEventListener('storage', updateModeWithoutTransitions)
9 |
10 | function updateMode() {
11 | let isSystemDarkMode = darkModeMediaQuery.matches
12 | let isDarkMode = window.localStorage.isDarkMode === 'true' || (!('isDarkMode' in window.localStorage) && isSystemDarkMode)
13 |
14 | if (isDarkMode) {
15 | document.documentElement.classList.add('dark')
16 | } else {
17 | document.documentElement.classList.remove('dark')
18 | }
19 |
20 | if (isDarkMode === isSystemDarkMode) {
21 | delete window.localStorage.isDarkMode
22 | }
23 | }
24 |
25 | function disableTransitionsTemporarily() {
26 | document.documentElement.classList.add('[&_*]:!transition-none')
27 | window.setTimeout(() => {
28 | document.documentElement.classList.remove('[&_*]:!transition-none')
29 | }, 0)
30 | }
31 |
32 | function updateModeWithoutTransitions() {
33 | disableTransitionsTemporarily()
34 | updateMode()
35 | }
36 | `
37 |
38 | export default function Document() {
39 | return (
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | )
50 | }
51 |
--------------------------------------------------------------------------------
/src/pages/about.mdx:
--------------------------------------------------------------------------------
1 | import { Contributors } from '@/components/pages/About'
2 |
3 | export const description = 'About the React Handbook.'
4 |
5 | # About the React Handbook
6 |
7 | 👋 Hey there
8 |
9 | My name is Eric, and I created the initial version of the React Handbook.
10 |
11 | **The goal for this website** is to cover the very nuanced details of working with React in production environments.
12 |
13 | We believe this guide to opinionated React practices is necessary because the core React team can't and shouldn't focus too much of their time trying to cover the ecosystem in the docs (especially without showing favoritism).
14 |
15 | **What you might call this guide**
16 | - An opinionated guide to advanced React patterns and practices
17 | - Some of the "gaps" in the official React docs that other writers can explain well
18 |
19 | ## Looking for Help
20 |
21 | If you're interested, you can help us by:
22 |
23 | 1. **Validation that the topics covered and the recommended approaches generally are agreed upon as best practices by the community.** This is specifically helpful if you are an expert/experienced in a particular facet of development (styling/CSS as an example) - we are not looking for people to read in detail the entire website, but more like skip to the spots where YOU have expertise and explain what you would change (if anything)
24 | 2. **Provide feedback for sections that are confusing, over-explained, or still not clear by the end of an article.** This is helpful from the exact opposite lens as point #1 above - if you are an expert in different facets of development than what is covered, but you really need to understand something you haven't ever dove into (testing or state-management for example) it's very helpful to get feedback when you still did not understand a topic very well after going through our material
25 | 3. **Help out with small or large issues encountered in the maintenance of this website.** While we don't expect anyone to clean up the dirty work, we do keep track of smaller "tasks" or things that need to get done that might not require a seasoned/expert opinion and are just generally related more to site maintenance. If you're looking for more of those green squares in your GH profile but can't find things to work on, help with these tasks would be greatly appreciated. Some examples might be things like typos/spell-checks or text formatting, while others might be more interesting such as large component refactors (more realistic to professional React development).
26 |
27 | ---
28 |
29 |
30 |
31 | You'll notice there's not much in-depth original content on this website. We mostly write a summary of a feature/library and then link off-site to the documentation for you to go and learn that technology in detail.
32 |
33 | _TLDR: We like pointing people in the right direction._
34 |
35 | | FAQ | Response |
36 | | --------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
37 | | Who are you and why should I trust that you know anything about React? | Honestly, there's no official answer we can give to this. None of us are on the React core team, and don't have any special certifications around React development or anything like that. We're just developers who have worked with web technologies for many years.
38 | | Why would I read this instead of the React documentation? | We definitely recommend starting with the Official React Documentation before coming here, as it helps to learn to "think in React" before you set off to build an app. If you've never built a web app before there are some starting points we can recommend, but this guide might be a little too advanced for you. |
39 | | What is the goal of this guide? | Essentially, to be the go-to bookmark (2nd to the docs, maybe) for engineers building React applications. To create a community around the concept of scalable, maintainable React code and how to achieve it (AKA "Best Practices", if those even exist). |
40 | | What was the initial need for this guide? | I Eric Diviney (the original author) worked at a consulting company where we built enterprise web apps and digital products for very large companies (brands like John Deere, Toyota, Pizza Hut, TopGolf - very recognizable American brands). Not all engineers were required to know React - but the nature of enterprise consulting meant there were always projects we needed to staff, and therefore we always had engineers learning or coming back to React at different times. There was no formal learning path for anyone to follow provided by the firm. I made the first version of this guide as a reference to bring as many people as possible up to speed with modern web development practices. |
41 |
--------------------------------------------------------------------------------
/src/pages/ecosystem.mdx:
--------------------------------------------------------------------------------
1 | export const description =
2 | 'Popular plugins and libraries to use in your React projects.'
3 |
4 | # Ecosystem
5 |
6 |
7 | Hi there, so we're looking for libraries and tools that can do the following:
8 |
9 | - useful things for 3d rendering / graphics / video-gaming in browsers
10 | - edge cases / difficult things to do in frontend apps
11 | - niche libraries that just REALLY fill out their use-cases
12 |
13 |
14 | React boasts a vast ecosystem of open-source libraries, plugins, and features that can help your team rapidly develop UIs and applications.
15 |
16 | Generally, to make our list below, the library in question needs to have support and active development/maintenance. The rules are not strict, something like 100K+ weekly downloads on npm and a release within the last 6-12 months.
17 |
18 | ---
19 |
20 | ## Premade Hooks
21 |
22 | - usehooks.com
23 | - usehooks-ts.com
24 |
25 | ## Utility Libraries
26 |
27 | Utility libraries typically bring an array of functions at your disposal, either all around a single domain (such as dates/timezones) or more generic (array sorting, object cloning, deep comparisons, etc.)
28 |
29 | - date-fns
30 | - use-local-storage-state
31 | - react-cookie
32 | - lodash
33 |
34 | ## Forms & Inputs
35 |
36 | The form libraries below can help you build complex forms, and the input components can bring non-standard browser input types (such as datepickers, multi-select dropdowns, etc.) into your application.
37 |
38 | - react-hook-form
39 | - react-final-form
40 | - rc-field-form
41 | - formik
42 | - We recommend zod or yup for form validation
43 |
44 | ### Form UI & Inputs
45 |
46 | For basic form elements like dropdowns, radio groups, checkboxes, we recommend headless UI libraries (read about them on our UI / Styling page).
47 |
48 | Input masking
49 |
50 | - react-number-format
51 | - react-text-mask
52 | - react-imask
53 |
54 | Select / Multi-Select
55 |
56 | - react-select
57 | - rc-tree-select
58 |
59 | Datepickers
60 |
61 | - react-dates
62 | - react-datepicker
63 | - react-calendar
64 | - react-day-picker
65 |
66 | ## Animations / Loading States
67 |
68 | - framer/motion
69 | - react-spring
70 | - react-loading-skeleton
71 |
72 | ## Drag & Drop / Resizing Elements
73 |
74 | - react-beautiful-dnd - Beautiful and accessible drag and drop for lists with React
75 | - react-dnd - Drag and Drop for React
76 | - react-draggable - React draggable component
77 | - react-resizable - A simple React component that is resizable with a handle
78 | - react-grid-layout - A draggable and resizable grid layout with responsive breakpoints
79 | - react-advanced-cropper - An advanced React component for image cropping
80 | - react-archer - Draw arrows between React elements
81 |
82 | ## Charts & Data Visualization
83 |
84 | - vx - Visualization components
85 | - victory - A collection of composable React components for building interactive data visualizations
86 | - react-vis - Data Visualization Components
87 | - recharts - Redefined chart library built with React and D3
88 | - nivo - Provides a rich set of data visualization components, built on top of the D3 and React libraries
89 |
90 | ## Tables / Data-Grids / Spreadsheets
91 |
92 | - react-table - A lightweight, fast and extendable datagrid for React
93 | - react-data-grid - Excel-like grid component built with React
94 |
95 | ## Toasts / Notifications
96 |
97 | - sonner
98 |
99 | ## Spotlight / File Viewers / Carousels
100 |
101 | - react-joyride - Create guided tours for your apps
102 | - react-pdf-viewer - A PDF viewer made for React
103 | - swiper - modern mobile touch slider
104 |
105 | ## Virtualization
106 |
107 | - react-window
108 | - tanstack-virtual
109 | - react-virtuoso
110 |
111 | ## Routing
112 |
113 | - react-router
114 | - tanstack-router
115 | - wouter
116 |
117 | ## Internationalization (I18N)
118 |
119 | - react-i18next
120 | - react-intl
121 |
--------------------------------------------------------------------------------
/src/pages/frameworks/alternate-tech-stacks.mdx:
--------------------------------------------------------------------------------
1 |
2 | # Alternate Tech Stacks with React
3 |
4 |
5 | Hi there, so we're looking for the following:
6 |
7 | - Any other common and battle-tested ways to ship React applications
8 | - React integrations with other devices, operating systems, etc.
9 | - Resources for building React apps with Astro, Qwik, or others that play well with React
10 |
11 | Please consider helping us out if you have any recommendations!
12 |
13 |
14 | ## Monorepos
15 |
16 | - Monorepos - How the Pros Scale Huge Software Projects // Turborepo vs Nx
17 | - Nx
18 | - Turborepo
19 |
20 | ## SPAs
21 |
22 | - React Admin - Build on REST/GraphQL APIs, using ES6, React and Material Design
23 | - React SPA / WordPress - WordPress-powered React apps
24 |
25 | ## Integrations with MVC / Backend Frameworks
26 |
27 | - React / Laravel with Intertia.js
28 | - Intertia.js also offers a Ruby on Rails integration, though Laravel is the only officially supported framework
29 | - Adding a Laravel Backend to a Remix App (Backend of Frontend pattern)
30 |
31 | ## Misc
32 |
33 | - wp-react-starter - Create WordPress plugins that use React, TypeScript, and PHP
--------------------------------------------------------------------------------
/src/pages/frameworks/nextjs.mdx:
--------------------------------------------------------------------------------
1 |
2 | # Next.js
3 |
4 |
5 | Hi there, so we're looking for the following:
6 |
7 | - plugins/libraries that solve a huge problem, and are only applicable to Next.js applications
8 | - tutorials/educational material that make Next.js more accesible
9 | - summarizations of core concepts required to build with Next.js, and off-site links to dive deeper
10 |
11 | Please consider helping us out if you have any recommendations!
12 |
13 |
14 | ## Basics
15 |
16 | - The Official Documentation
17 | - Official Next.js Web App Tutorial
18 | - Data-Fetching in Next.js
19 |
20 |
21 | 1. API routes
22 | 2. Middleware
23 | 3. Code splitting
24 | 4. TypeScript Support
25 | 5. Server-handled routing (via file structure)
26 | 6. Automatic Image Optimization
27 | 7. Zero-config production optimization
28 | 9. React Server Components
29 | 9. Static Site Generation (SSG) / Server Side Rendering (SSR) / Hybrid
30 |
31 |
32 | ## Learn
33 |
34 | - Next.js in 100 Seconds (Plus Free Beginner Tutorial) - Fireship
35 | - Next.js 13 Full Course 2023 - JavaScript Mastery
36 | - Next.js Full Course for Beginners - Dave Gray
37 | - nextjsweekly.com
38 |
39 | ## Why do people like using Next.js?
40 |
41 | This reddit thread is the inspiration for this section, and some of the responses are summarized here:
42 |
43 | 1. The first and most upvoted response is one that appreciates the ease of maintenance in a project that supports Server-Side React rendering. It's not that the setup is hard - it's that the APIs and planning haven't all settled just yet and therefore as new updates get pushed and the features move along - maintenance and upkeep becomes a challenge.
44 | 2. General consensus that the Next.js documentation is good
45 | 3. It's easy to make frontend devs a bit closer to "full-stack" by expanding what is possible in a React framework
46 | 4. The NEED for Server-Side rendering in an application/organization where everyone already knows React well is a great fit (teams are productive quickly)
47 |
48 |
49 | ## Misc Resources
50 |
51 |
52 | - shadcn/ui
53 | - shadcn/taxonomy
54 | - getstaticprops.com
55 |
56 |
57 |
58 | - blitz-js/blitz
59 | - trpc/trpc
60 | - t3-oss/create-t3-app
61 | - ixartz/Next-js-Boilerplate
62 | - akd-io/create-next-stack
63 |
64 |
65 |
66 | - nextauthjs/next-auth
67 | - unicodeveloper/awesome-nextjs
68 | - outstatic.com - CMS for Next.js
69 |
70 |
--------------------------------------------------------------------------------
/src/pages/frameworks/react-native.mdx:
--------------------------------------------------------------------------------
1 | export const description =
2 | 'How to structure your React Native project and format your components.'
3 |
4 | # React Native Project Standards
5 |
6 | There's no reason you can't or shouldn't follow a directory-setup like we describe on our normal Project Standards page.
7 |
8 | ## Intro to React Native
9 |
10 | - React Native Tutorial
11 | - From Web to Native with React
12 | - reddit.com/r/reactnative
13 |
14 | ## Basic UX for Touch Devices
15 |
16 | **Cancellation** - Give your users the ability to "cancel" a touch/gesture right in the middle of it (for example, by dragging their finger away). Read more about gesture best practices here.
17 |
18 | **Stick to Buttons With Visual Feedback** - Various buttons provided by React Native have their own feedback controls which provides visual aid to the user. It is recommended best practice to implement visual feedback for a gesture touch to keep the user informed of action results. Traditionally, this would've been implemented with things like `TouchableOpacity` - but the recommended component to use for future apps would be the Pressable.
19 |
20 | ## Ecosystem / Packages
21 |
22 | A very useful directory for browsing open source packages and functionality you should consider using is the React Native Directory. You can filter by the platform you're deploying to as well.
23 |
24 | Furthermore, there will be times you need to use "Native Modules" to interact with device-specific APIs that JavaScript cannot provide. At the time of writing, `Native Modules` and `Native Components` are deprecated and will eventually transfer to the new and improved `Turbo Native Modules` and `Fabric Native Components`. For more info, visit the Native Modules Intro from the docs.
25 |
26 | ## Component Tips
27 |
28 | There's nothing particularly unique in React Native that would keep you from implementing the same general project practices we recommend on our Project Structure page. So for organizing your component files and folder structure we do recommend the same approach.
29 |
30 | However, there are some particular catches when developing with React-Native, so we'll try to explain those below:
31 |
32 |
33 | ```jsx {{ title: 'JavaScript' }}
34 | // Occasionally you will run into scenarios where Platform-specific code is required.
35 | // You can use the Platform import for these purposes.
36 | import { Platform, StyleSheet } from 'react-native'
37 |
38 | // & are two critical components you should frequently use
39 | // SafeViewArea - To ensure your views don't get cut off by odd iPhone screen shapes (wrap your View layer in this)
40 | import { SafeAreaView } from 'react-native'
41 | // FlatList - an extremely performant method of rendering list-like components. Uses virtualization under the hood.
42 | import { FlatList } from 'react-native'
43 |
44 | // Conditionally apply styles depending on platform of user
45 | const styles = StyleSheet.create({
46 | container: {
47 | flex: 1,
48 | ...Platform.select({
49 | ios: {
50 | // iOS-only styles
51 | },
52 | android: {
53 | // Android-only styles
54 | },
55 | }),
56 | },
57 | })
58 |
59 | // or, reference the Platform.OS property directly to conditionally run code in your components
60 | switch (Platform.OS) {
61 | case 'ios':
62 | case 'android':
63 | case 'macos':
64 | case 'windows':
65 | case 'web':
66 | }
67 |
68 | if (Platform.OS === 'ios' || Platform.OS === 'android') {
69 | // target whichever system you need
70 | }
71 | ```
72 |
73 |
74 | ## Performance & Optimization Tips
75 |
76 | With React Native being a leader in producing mobile applications, it is imperative to consider performance caveats and best practices. For more, please refer to the React Native Performance Overview Docs. Below are some misc tips for optimization.
77 |
78 | **Image performance** is a crucial when working with a native application as memory constraints means unoptimized image use could lead to crashes, especially when using static image resources. Here are a number of ways to handle for this.
79 |
80 | - react-native-fast-image package - Provides a `FastImage` component that integrates with the `SDWebImage`(iOS) and `Glide` (Android) objects which, as you guessed, loads images much faster.
81 | - **Proper image Formats** - You may want to consider using formats like PNG or WEBP format for reducing binary size of images for both platforms. This can reduce images to 1/3 of the original size.
82 |
83 | **RAM Format** - For iOS, you can produce your application in RAM format for a single indexed file. As the docs state:
84 |
85 | > "... This is useful for apps that have a large number of screens which may not ever be opened during a typical usage of the app. Generally it is useful to apps that have large amounts of code that are not needed for a while after startup..."
86 |
87 | With use of Hermes, this is enabled by default.
88 |
--------------------------------------------------------------------------------
/src/pages/fundamentals.mdx:
--------------------------------------------------------------------------------
1 | export const description =
2 | 'The fundamentals required to excel in development with React.'
3 |
4 | # React Fundamentals
5 |
6 |
7 |
8 |
Resources for learning JavaScript & TypeScript
9 |
Core React concepts you absolutely need to know
10 |
Advanced understanding of render/re-render behavior in React
11 |
More crash courses & tutorials to help you learn React
12 |
13 |
14 |
15 | ## JavaScript & TypeScript (JS/TS)
16 |
17 | **JavaScript**
18 |
19 | - Eloquent JavaScript - A good desk reference to keep bookmarked. Read thoroughly for a high-level understanding of the language.
20 | - Clean Code JavaScript - Tips on how to write clean, simple, understandable JavaScript.
21 | - JavaScript.info - Modern JavaScript Tutorial
22 | - Learn JavaScript - Interactive JavaScript Tutorial
23 | - The Odin Project - Full Stack JavaScript Development Course
24 | - Egghead.io - Learning `ES6`
25 | - 33 JS concepts - 33 Concepts Every JavaScript Developer Should Know
26 | - ExploringJS - Book covering ECMAScript 6 (ECMAScript 2015)
27 |
28 | **TypeScript**
29 |
30 | A JavaScript (JS) developer can pick up the basics of TypeScript (TS) in about 10 minutes. But learning TS is more than just adding "types" to your variables here and there. It's about removing the possibility of a bug you'll probably run into if you wrote an application in pure JS. It's likely you already have an internal mental model of "data structures" when you're coding in JS - TypeScript just solidifies those mental models (in your head) into actual "rules" that can apply to your code and how it gets used.
31 |
32 | The class of bugs you're getting rid of are all those pesky (…cannot read… 'undefined') errors in the console. If you're ready to get started, check out some of the links below:
33 |
34 | - Why Create TypeScript?
35 | - TS for the New Programmer - TypeScript explained for beginners
36 | - stackoverflow.com - What is TypeScript and why would I use it in place of JavaScript? [closed]
37 | - Why TypeScript?
38 | - Beginner's TypeScript - A (free) interactive video course by Matt Pocock
39 | - React with TypeScript - Another free video course by Matt Pocock
40 | - Total TypeScript Essentials
41 | - No BS TS - A (free) video course by Jack Herrington
42 | - Learn TypeScript - Full Tutorial
43 | - TypeScript errors - How to fix your confusing TypeScript errors
44 | - React TypeScript Cheatsheet
45 |
46 | It is not an exaggeration to call TypeScript an entire programming language. The good news is you can adopt TS complexity only as it aids you. Sometimes you might have to temporarily level up or step outside your level of expertise to complete a feature. For example, if a library gives you code to work with and it's more advanced TS than you can ordinarily write on your own, it's perfectly acceptable to use it. In most cases, adopting it incrementally in your JS projects and code is pretty painless, and it allows you to learn at your own pace without halting development altogether.
47 |
48 | ## Applying JS/TS to React
49 |
50 | To give you a quick idea of the current state of React, check out this 2-minute clip by Fireship titled React in 100 Seconds. While it barely scratches the surface, it quickly communicates why React is so popular today (an important context to keep in mind).
51 |
52 | Some JS fundamentals you'll want to brush up on are **Events, Promises, Arrays**. Events drive interactivity in web applications. Understanding events at their core and how they propagate through the DOM (in the correct hierarchy and order) is critical to understanding browser behavior. To understand events, you should start by reading An Interactive Guide to JavaScript Events by Aleksandr Hovhannisyan.
53 |
54 | Asynchronous JavaScript allows us to write UIs and apps with non-blocking interactivity. At the same time, potentially long-running processes run in the background, which helps us defer behavior until those processes have been completed. Promises are the primary way of dealing with asynchronous behavior and the associated information.
55 |
56 | Arrays have developed as of `ES6` and now provide rich means of manipulating datasets. Read more about the functions of Arrays in JavaScript.
57 |
58 | ## React Concepts You MUST Know
59 |
60 | Now, moving onto the **React API**, JSX is a declarative way to describe our UI. React allows us to ignore the chaos of browser DOM APIs for rendering our apps (or mobile rendering in the case of react-native). You're really going to want to know JSX.
61 |
62 | Below are some specific recommended articles both in the docs and from various sources to help you "think" like a React developer. We recommend them precisely because they help you build the mental model of how React works:
63 |
64 | - Thinking in React
65 | - Responding to Events (like clicking, typing, scrolling, etc.)
66 | - Describing the UI
67 | - Managing State (locally, in components)
68 | - Built-In React Hooks (hooks reference)
69 | - A Complete Guide to useEffect - a very detailed article on the nuance of useEffect by core-team member Dan Abramov
70 | - Myths about useEffect
71 | - Escape Hatches
72 | - Common Beginner Mistakes with React
73 |
74 | ### Really Understanding How Rendering Works in React
75 |
76 | Many newcomers to React think a performant React app means simply cutting down the number of "re-renders" - but to really master performant React code you need to understand when/how/why re-renders happen, and what's actually happening when a re-render occurs.
77 |
78 |
79 |
80 | - Rendering in React
81 | - Why React Renders
82 | - Why React Re-Renders
83 | - A (mostly) complete guide to react rendering behavior
84 | - Everything on developerway.com that has to do with re-rendering
85 | - React, Visualized
86 | - A Visual Guide to React Rendering
87 | - Interactive CodeSandbox that shows how/when parents re-render any direct child components used in the render (NOT to be confused with the `children` prop, which do NOT always trigger re-renders if/when they change)
88 | - Notice that `Component B` in this example is memoized with `memo()`
89 | - React recursively re-renders child components, but the `children` prop is special
90 | - assuming your component passes the children prop through and simply renders it, re-renders of `{children}` will not always cause the parent to re-render
91 | - Timeline of a React Component With Hooks
92 | - An interactive timeline showing how a React component with hooks runs
93 | - Parents & Owners in React: Rendering Performance
94 | - Being aware of the distinction between parent and owner components can help you isolate updates and improve rendering performance.
95 |
96 |
97 |
98 |
99 |
100 | ## Courses & Video Tutorials
101 |
102 | Crash courses and more you can blow through below.
103 |
104 |
105 | - The Beginner's Guide to React - Video Course by Kent C. Dodds
106 | - Egghead.io (react lessons - free tier) - A catalog of React tutorials/lessons
107 |
108 |
109 |
110 | - Interactive React Tutorial - Build React Projects with Jad Joubran
111 | - Learn React with Bob Ziroll
112 |
113 |
114 |
115 | - How React Works - 2023
116 | - React Handbook - Tutorial by Flavio Copes. In all honesty: he beat us to the name "React Handbook"
117 |
118 |
--------------------------------------------------------------------------------
/src/pages/index.mdx:
--------------------------------------------------------------------------------
1 |
2 | export const description =
3 | 'Modern approaches to architecture and feature development for production-ready React apps.'
4 |
5 | # The React Handbook **⚛🤌**
6 |
7 | Modern approaches to architecture and feature development for production-ready React apps. {{ className: 'lead' }}
8 |
9 | ## Why Read This Instead of the React Docs?
10 |
11 | If you haven't ever worked with React before, this guide might seem a little dense.
12 |
13 | There are some fundamentals we can recommend, but to put it bluntly: you should not be reading this guide before you've read the official docs.
14 |
15 | The docs will help you learn React, but the React Handbook will help you learn the **ecosystem**.
16 |
17 | ***There's a lot of great content/advice out there and we want to centralize it.*** The flexibility of React forces us to make so many choices as engineers/architects - and that's precisely why there's a need for a guide like this.
18 |
19 | The recommendations here are opinionated _purposefully_. You can implement only what you see fit for your project and team. The baggage that comes with being the most popular UI framework in the world - is that there is a ton of low-quality learning content on the internet. We want to make the good content easy to find.
20 |
21 | ## A Bookmark, Not a Course
22 |
23 | This guide isn't meant to be a typical course that you start and finish. It's a reference, a website you bookmark and return to when encountering something in the React ecosystem that you'd like to research more.
24 |
25 | We're trying to cut down the time that the community spends having to research the best React practices on Google, Reddit, Twitter, YouTube, Dev.to, Frontendmasters.com, etc.
26 |
27 | By using this site, you'll spend less time searching the internet for good learning resources and instead spend more time shipping your React applications in a way that will scale.
28 |
29 | It's meant to be easily skimmable, so you can jump to the current problem at hand.
30 |
31 | You're welcome to read from start to finish (you'll probably learn something along the way), but that's not necessarily the use-case we envisioned.
32 |
33 | ## Less Hot Takes, More Sincerity
34 |
35 | Lately, the Twitter angst and Reddit threads have gotten a little too click-baity and dogmatic. Everyone's posting hot takes, memes, engagement bait lately. We're not going to engage in any of that on this site.
36 |
37 | ***The goal is simply to compile one of the best resources on the internet for learning React development.***
38 |
39 | ## How to Navigate this Website
40 |
41 | The search (at the top of the page) is pretty great.
42 |
43 | The navigation (on the left side of the page) keeps track of where you are on each page, and what else you can explore. You can toggle the sidebar to stay open, or keep it hidden so you can focus.
44 |
45 | Finally, there are lots of sections/topics that you can expand when you want more detail. They'll look something like this:
46 |
47 |
48 | We're looking for contributors!
49 | If you are interested in working in open-source/public, you can get involved with us on GitHub.
50 |
51 |
52 | We love feedback of all kinds, just please keep in mind that we are working professionals that try to maintain this website in our spare time only. We are open to all suggestions, provided you have a positive attitude when making the suggestion. We don't assume any ill intent, ever.
53 |
--------------------------------------------------------------------------------
/src/pages/react-performance-optimization.mdx:
--------------------------------------------------------------------------------
1 |
2 | export const description = 'Ship fast and performant UIs, a great start to positive UX.'
3 |
4 | export const sections = [
5 | { title: 'Loading vs Runtime', id: 'loading-vs-runtime'},
6 | { title: 'Measuring Loadtimes', id: 'measuring-loadtimes'},
7 | { title: 'Optimizing Loadtimes', id: 'optimizing-loadtimes'},
8 | { title: 'Measuring Runtimes', id: 'measuring-runtimes'},
9 | { title: 'Optimizing Runtimes', id: 'optimizing-runtimes'},
10 | { title: 'UX Performance Best Practices', id: 'ux-performance-best-practices'},
11 | { title: 'Typical Performance Hangups', id: 'typical-performance-hangups-in-react'},
12 | { title: 'Misc. Articles', id: 'misc-articles'}
13 | ]
14 |
15 | # React Performance & Optimization
16 |
17 |
18 |
19 |
Loadtime performance vs Runtime performance
20 |
How to measure and improve both (loadtime and runtime)
21 |
React-specific ways to optimize your project/codebase
22 |
How to make performance work toward the best UX
23 |
24 |
25 |
26 | Performance in React apps can be thought of in ***2 ways***:
27 |
28 | 1. Loading Performance - Compressing & loading code/assets (mostly *Non-React* things)
29 | 2. Runtime Performance - CPU & rendering issues (mostly *React-specific* things)
30 |
31 | ## Loading vs. Runtime
32 |
33 | Loading Performance - This is a measure of how fast the content is loaded when a user visits your webpage. Some specific metrics are First Contentful Paint (FCP), Largest Contentful Paint (LCP), First Input Delay (FID), TTI (Time to Interactive), and maybe a "Speed Index".
34 |
35 | Runtime Performance - This is a measure of how "smooth" your application runs and functions after the initial load. Some specific metrics for this might be "frame rate", "CPU", and "Memory Usage".
36 |
37 | ## Measuring Loadtimes
38 |
39 | - PageSpeed Insights
40 | - WebPageTest.org
41 | - Lighthouse
42 | - UnLightHouse
43 |
44 | ## Optimizing Loadtimes
45 |
46 | Send as little code/media as possible over the network, and optimize everything
47 | - Utilize GZip compression server-side to compress all in-flight HTTP requests
48 | - Optimize all images and videos included in the bundle
49 | - Lazy load images
50 | - Building and Minifying all project assets to CSS / JavaScript
51 | - Various Methods of Code Splitting
52 | - Vite bundles will have some code-splitting done by default
53 | - What is Lazy Loading & how to use lazy and Suspense to lazy-load components or routes in your React app
54 | - Server-Side Rendering (SSR) and Static Site Generation (SSG) can improve the First Contentful Paint and Time to Interactive metrics, as they allow the browser to render the page more quickly (and are accessible by search engines).
55 | - Adding SSR / SSG to an existing project is no small feat and will take you more than an afternoon. Try to evaluate early on if your application would benefit from these technologies so you can configure your project the right way from the start.
56 |
57 | ## Measuring Runtimes
58 |
59 | Modern React is pretty fast by default. Unless you're building complex components/features - you don't need to reach for optimization tactics until you notice a component/feature behaving slowly. The best advice to follow:
60 |
61 | 1. Don't optimize too soon
62 | 2. Know what to measure
63 |
64 | In modern React apps, most of the performance issues you'll run into can probably be simplified down to rendering problems (either too slow, or too much). The visual in the tweet below explains how rendering can cause cascading effects across a large application.
65 |
66 |
67 |
68 |
69 | Read more from Alex Sidorenko in his series A Visual Guide to React Rendering.
70 |
71 |
72 |
73 |
74 |
75 | Other helpful resources for understanding how to measure runtime performance in React apps:
76 |
77 | - Measuring Performance in Chrome
78 | - Debugging in the Browser
79 | - Devtools Coverage - shows how much of your code is being shipped but then NOT running (while session is recording)
80 | - Use the Profiler to measure rendering performance of a React tree programatically
81 | - How to Detect Slow Renders in React?
82 | - How many re-renders are too many?
83 |
84 | ## Optimizing Runtimes
85 |
86 | Runtime performance issues usually boil down to two types of issues:
87 |
88 | 1. Fixing Slow Renders
89 | - Fix the slow render before you fix the re-render
90 | - Understand that ES6 is single-threaded, therefore laggy behavior can happen easily
91 | - Offload expensive work that shouldn't block rendering to Web Workers
92 |
93 | 2. Fixing Profuse Re-Renders
94 | - Use Refs for state & values that shouldn't cause re-renders (or that aren't rendered at all)
95 | - Be careful of setting state in an effect or outside of event-handlers / conditions
96 |
97 |
98 | ***Memoization & Virtualization*** can solve slow renders or profuse re-renders in different ways:
99 |
100 | - use memo to memoize components and cut down pointless re-renders of child components when their props aren't changing
101 | - You should probably use `memo()` around any component immediately under Context Provider
102 | - See `memo()` in action with a visual example
103 | - use useMemo() to memoize specific work *within* your components, cutting down the render time by skipping it if the recalculation isn't needed
104 | - A Visual Guide to React Rendering - useMemo
105 | - use useCallback() to memoize (cache) functions that are created for use in your components, cutting down the render time by skipping it if the function doesn't need to be recreated
106 | - A Visual Guide to React Rendering - useCallback
107 | - use virtualization for efficiently rendering large lists of datasets, cutting down render time
108 | - A library called Million.js has been making the rounds lately, apparently able to replace the VDOM in React with a version that's up to ***70% faster***.
109 |
110 | ## UX Performance Best Practices
111 |
112 | - Consider throttling/debouncing frequent updates in the DOM. Humans can't see/process more than a few subtle updates in 1 second (1000 milliseconds), so there's no computational need to update something 100's of times per second.
113 | - Read more about how fast of an interaction is too fast for humans
114 | - For actual changes in the UI/data that's being shown, try not to show more than 4-5 updates per second. Any more, and the humans using your app won't even be able to tell the difference between each update, making it pointless.
115 | - RxJS has traditionally been a great resource for throttling data throughput in a JS application
116 | - Treat loading/pending states that are active for < 400ms uniquely, you should do either:
117 | - Simply don't show the loading state, as "delay" in the app that's < 400ms probably won't be perceivable by the users anyways
118 | - If you show the loading/pending state - require a minimum of ~400ms before switching back to a non-loading state
119 |
120 |
121 | ## Typical Performance Hangups in React
122 |
123 | - Pitfalls of `Context` and `useContext`
124 | - React Context Dangers
125 | - React Context Performance
126 | - Using SVGs in JSX can sometimes result in bloated bundles
127 |
128 | ## Misc. Articles
129 |
130 | More resources about optimizing JavaScript/React performance
131 |
132 | - Improving React Interaction Times by 4x
133 | - Improve the Performance of your React Forms
134 | - One Simple Trick to Optimize React Re-Renders
135 | - Speeding up the JavaScript ecosystem - one library at a time
136 | - Making Tanstack Table 1000x faster with a 1 line change
137 | - Optimizing React performance without refs and memo
138 | - React Performance Checklist - Cory House
--------------------------------------------------------------------------------
/src/pages/semantics.mdx:
--------------------------------------------------------------------------------
1 | export const description =
2 | 'Learn to write semantically valid markup in your React apps.'
3 |
4 | # Accessibility & Semantics
5 |
6 |
7 |
8 |
What is Semantic HTML
9 |
Why Semantic HTML / Accessibility is important
10 |
Bad Practices
11 |
12 |
13 |
14 | ## What is Semantic HTML
15 |
16 |
21 |
image and description provided by semrush.com
22 |
23 | > Semantic HTML, also known as semantic markup, refers to the use of HTML tags that convey the meaning—or semantics—of the content contained within them.
By adding semantic HTML tags to your pages, you provide additional information that helps define the roles and relative importance of the different parts of your page.
24 |
25 | **Misc**
26 |
27 | - `A11Y` is an acronym for "Accessibility"
28 | - Introduction to ARIA (Accessible Rich Internet Applications).
29 | - If you would like to adhere to WAI-ARIA in your application, we recommend some headless UI libraries on the ecosystem page that follow the WAI-ARIA design patterns.
30 | - Take caution when adding/implementing ARIA manually in your project, as it is frequently implemented incorrectly and can actually make your application LESS usable.
31 |
32 | **Accessibility Cheatsheet:**
33 |
34 | - Accessibility cheat sheet
35 |
36 | **Learn more:**
37 |
38 | - HTML: A good basis for accessibility
39 | - HTML Elements Reference
40 | - A beginner's guide to web accessibility
41 | - 10 Blunt Things I Wish I Could Tell Clients - Karl Groves, Web Accessibility Expert
42 |
43 | ## Why is Semantic HTML Important?
44 |
45 | 1. Make Your Website / Web App Accessible
46 | 2. Search Engine Optimization (SEO)
47 | 3. Clearer Code / Maintainability
48 |
49 | ## Bad Practices to Avoid
50 |
51 | Do NOT treat accessibility as something you can add to your app after the development phase but before launching. You are pretty likely to either miss accessibility concerns altogether or create solutions that end up causing more trouble for people trying to access your app.
52 |
53 | Instead of thinking of A11Y as something you "sprinkle" in right before the production launch, try to make it a fundamental aspect of your code-writing process. Give your team cheatsheets like the one at the bottom of this page to make it easier for them to implement accessible interfaces, make it a point to double-check any HTML markup added in a PR review for better semantic options.
54 |
55 | By making accessibility a "ground up" philosophy on your team, you will be much less likely to miss gaping accessibility issues in your projects.
56 |
--------------------------------------------------------------------------------
/src/pages/styling.mdx:
--------------------------------------------------------------------------------
1 | export const description = 'The best ways to style your React application.'
2 |
3 | # Styling & UI Libraries
4 |
5 |
6 | Helpful tip: before using any libraries below, you should check your IDE for
7 | plugins that might improve the developer experience of using it. For example,
8 | if you use Tailwind, the Tailwind
9 | IntelliSense
10 | plugin (which recommends classnames in the auto-complete dropdown) and
11 | Prettier coupled with the
12 | Tailwind Prettier Plugin
13 | (enforces consistent ordering of classnames in your markup) in Visual
14 | Studio Code might be useful for your team.
15 |
16 |
17 | ## Utility Approach
18 | - tailwindcss
19 | - unocss
20 | - tachyons
21 |
22 |
23 | - Use the inline fold vscode plugin to collapse long className strings when you're not focused on them with the cursor - Inspired by Cory House
24 | - The Tailwind IntelliSense vscode plugin gives you auto-complete
25 | - If you purchase tailwindui you'll get access to tons of pre-made components + templates
26 | - shadcn/ui - Open Source UI Components
27 | - Preline - Open Source UI Components
28 | - awesome-tailwindcss repository on github.com is full of awesome stuff
29 |
30 |
31 |
32 | ## CSS / CSS-in-JS
33 | - CSS modules
34 | - styled-components
35 | - emotion
36 | - vanilla-extract
37 | - linaria
38 |
39 | ## Component Libraries
40 |
41 | Most UI libraries will come with a "theme" or global way to configure certain things like colors, fonts, etc. — but in general, the components render with opinionated styles already applied.
42 |
43 | If your app is small enough, it may be simpler to reach for a headless solution (more below) and create the critical components in your app than try to overwrite or customize an entire library.
44 |
45 | - Material UI
46 | - Twitter Bootstrap
47 | - Chakra UI
48 | - NextUI
49 | - Ant Design
50 | - Semantic UI
51 | - Fluent UI
52 | - Carbon Design System
53 | - Pico CSS
54 | - Mantine
55 |
56 |
57 | If you need a lot of customization or control over the presentation of the UI,
58 | you should consider a headless solution.
59 |
60 |
61 | ## Headless Component Libraries
62 |
63 | - Radix UI / Radix Themes
64 | - Headless UI
65 | - Base UI
66 | - React Aria
67 | - Ariakit
68 |
69 | ## Recommended Combinations
70 |
71 | - Radix UI + tailwind
72 | - Headless UI + tailwind
73 | - Chakra UI + emotion
74 | - Base UI + CSS Modules / styled-components
75 |
76 | ## Universal / Mobile Component Libraries
77 | - React Native Paper
78 | - NativeBase
79 | - tamagui
80 | - React Native Elements
81 | - Framework7
82 | - Ionic
83 |
84 | ## Misc / SVG Icons
85 |
86 | - Demystifying Styled Components - Josh Comeau
87 | - shadcn/ui - Radix + Tailwind components to copy/paste into your project
88 | - Lucide
89 | - Heroicons
90 |
--------------------------------------------------------------------------------
/src/pages/team/eric-diviney.mdx:
--------------------------------------------------------------------------------
1 | export const description =
2 | 'About the authors and why they built the React Handbook.'
3 |
4 | # Hi, I'm Eric Diviney
5 |
6 | ## I want to help you build React apps
7 |
8 |
13 |
14 | The React Handbook is a website primarily maintained by me, Eric Diviney. I'm a software engineer building things at Dialexa, an IBM company. {{ className: 'lead' }}
15 |
16 | Here's a little about me and why I built this website (and what I think about web development in general).
17 |
18 | ## 1) Why do I like React? Why is React so popular?
19 |
20 | So, this is just my perspective, far from the complete history. If you want to really understand the history of React, I recommend this documentary (it's fantastic, seriously). Anyways, here's why I think React is great:
21 |
22 | - React was invented at the perfect time - JavaScript was evolving so quickly, and new tools were being invented all the time. There was strong demand for a generic library that was easily approachable and simplified building UIs. React fit this need perfectly at the time.
23 | - React is very simple (NOT easy, simple) - while this may be a controversial point for some, React's simple-but-flexible API is not a very steep learning curve. I don't want to call it _easy_, but the API, in our opinion, is much simpler than its counterparts, and also why we prefer it for building UIs.
24 | - JSX is awesome - At first, it was demonized, but now it's loved. Granted, JSX is nothing react-specific (you can use JSX in just about any modern framework). JSX is a declarative way to define your UI and its hierarchy and feels naturally intuitive to web developers because of its XML/HTML-like syntax.
25 | - React focused on the right things (at the time) - Instead of shipping the entire kitchen sink (routing, data fetching, styling, etc.) it just focused on the rendering of HTML. This allowed the ecosystem to develop around the library and surfaced the right tools needed by developers. This early (but critical) choice to focus on the right set of features is, in my opinion, what truly unlocked the ecosystem that we enjoy today. Of course, meta-frameworks all ship with opinionated methods of routing, data-fetching, and styling nowadays, but that's because now we see React can definitely still shine if decisions like those are made for us. It lets developers focus more on our application.
26 | - React is the most popular UI framework in the world now. According to various sources, one can reasonably conclude React is very likely to continue its growth trajectory in the near future (next five years) from these sources:
27 | - State of JS
28 | - Stack Overflow Survey
29 | - Stack Overflow Trends
30 | - Statista
31 |
32 | ## 2) How do I keep up with React/JavaScript?
33 |
34 | First, some great (free) resources
35 |
36 | - Clean Code JavaScript - how to write clean, simple, understandable JavaScript
37 | - Typescript for new programmers
38 | - JavaScript | MDN
39 | - Subreddits (interesting libraries are posted and discussions by library maintainers are fruitful)
40 | - /r/javascript
41 | - /r/learnjavascript
42 | - /r/reactjs
43 | - /r/react
44 | - My favorite twitter accounts:
45 | - Tanner Linsley
46 | - Dan Abramov
47 | - Jenna Smith
48 | - Josh Comeau
49 | - Ryan Florence
50 | - Alex Sidorenko
51 | - Ken Wheeler
52 | - Sarah Drasner
53 | - Kent C. Dodds
54 | - Michael Jackson
55 | - Andrew Clark
56 | - Cassidy Williams
57 | - Sébastien Lorber (this week in React)
58 | - Cory House
59 | - shadcn
60 | - My favorite websites/blogs/misc:
61 | - alexsidorenko.com
62 | - ui.dev/blog
63 | - developerway.com
64 | - github.com/coryhouse/reactjsconsulting
65 | - joshwcomeau.com
66 | - The only newsletters I subscribe to:
67 | - thisweekinreact.com
68 | - Next.js Weekly
69 |
70 | I've paid thousands over my career. It's very rare that a paid course/lesson sticks with me, the following list are those resources that just took me to a completely new level as a developer, I highly recommend them to anyone looking to further their career in frontend development:
71 |
72 | - Just JavaScript by Dan Abramov
73 | - Epic React Dev by Kent C. Dodds
74 | - Advanced React by Nadia Makarevich
75 |
76 | ## 3) Some of my favorite technologies for building software
77 |
78 | - React / React Native
79 | - TypeScript
80 | - TailWind
81 | - Radix UI
82 | - Laravel (PHP)
83 | - Flask (Python)
84 |
85 | ## 4) Arguments I Care About
86 |
87 | - Philosophies to live by:
88 | - KISS (Keep It Simple, Stupid)
89 | - "Great advice, hurts my feelings every time"
90 | - Strong Opinions, Loosely Held
91 | - "When the facts change, I change my mind. What do you do, sir?"
92 | - Simple Code > Clever One-Liner that requires a comment to understand
93 | - Everybody loves a good TODO left in the code. But you're truly a hero if you also put it in the backlog
94 | - Frontend preferences
95 | - TypeScript > JavaScript
96 | - Don't use `any` in TypeScript unless you have exhausted reasonable attempts to solve it (or consulted the TS guru on your team)
97 | - In general, too many apps built today are SPA's
98 | - Also, the SPA gets a bad wrap. If the whole app is behind Authentication, SPAs can be a great approach
99 | - The linter should require semicolons at the end of statements. Ya'll are getting ridiculous!
100 | - Tailwind > Traditional CSS (because I don't spend time having to name everything)
101 |
102 | ## 5) Arguments I Don't Care About
103 |
104 | - Tabs vs spaces (just pick one so everyone is consistent)
105 | - camelCase vs snake_case (same reason above, but honestly I do prefer camelCase)
106 | - Sass vs Styled Components vs Post CSS (if we're writing CSS, I care little how we do it, as long as we all do it consistently)
107 | - NeVeR uSe PHP (PHP is awesome) (and WordPress is _alright_)
108 | - Anything that results in bike-shedding
109 |
--------------------------------------------------------------------------------
/src/pages/topics.mdx:
--------------------------------------------------------------------------------
1 | import { Topics } from '@/components/Topics'
2 |
3 | export const title = 'React Topics'
4 |
5 | export const description = 'Topics covered by the React Handbook.'
6 |
7 | ## Jump right in
8 |
9 | If you're familiar with Web Development and/or React, the topics in the sidebar should be pretty digestible. Below you'll find a description for each section.
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/styles/tailwind.css:
--------------------------------------------------------------------------------
1 | :root {
2 | --shiki-color-text: theme('colors.white');
3 | --shiki-token-constant: theme('colors.sky.300');
4 | --shiki-token-string: theme('colors.sky.300');
5 | --shiki-token-comment: theme('colors.zinc.500');
6 | --shiki-token-keyword: theme('colors.sky.300');
7 | --shiki-token-parameter: theme('colors.pink.300');
8 | --shiki-token-function: theme('colors.violet.300');
9 | --shiki-token-string-expression: theme('colors.sky.300');
10 | --shiki-token-punctuation: theme('colors.zinc.200');
11 | }
12 |
13 | @tailwind base;
14 | @tailwind components;
15 | @tailwind utilities;
16 |
--------------------------------------------------------------------------------
/tailwind.config.js:
--------------------------------------------------------------------------------
1 | /** @type {import('tailwindcss').Config} */
2 | module.exports = {
3 | content: ['./{src,mdx}/**/*.{js,mjs,jsx,mdx,ts,tsx}'],
4 | darkMode: 'class',
5 | theme: {
6 | fontSize: {
7 | '2xs': ['0.75rem', { lineHeight: '1.25rem' }],
8 | xs: ['0.8125rem', { lineHeight: '1.5rem' }],
9 | sm: ['0.875rem', { lineHeight: '1.5rem' }],
10 | base: ['1rem', { lineHeight: '1.75rem' }],
11 | lg: ['1.125rem', { lineHeight: '1.75rem' }],
12 | xl: ['1.25rem', { lineHeight: '1.75rem' }],
13 | '2xl': ['1.5rem', { lineHeight: '2rem' }],
14 | '3xl': ['1.875rem', { lineHeight: '2.25rem' }],
15 | '4xl': ['2.25rem', { lineHeight: '2.5rem' }],
16 | '5xl': ['3rem', { lineHeight: '1' }],
17 | '6xl': ['3.75rem', { lineHeight: '1' }],
18 | '7xl': ['4.5rem', { lineHeight: '1' }],
19 | '8xl': ['6rem', { lineHeight: '1' }],
20 | '9xl': ['8rem', { lineHeight: '1' }],
21 | },
22 | typography: require('./typography'),
23 | extend: {
24 | boxShadow: {
25 | glow: '0 0 4px rgb(0 0 0 / 0.1)',
26 | },
27 | maxWidth: {
28 | 'lg': '33rem',
29 | '2xl': '40rem',
30 | '3xl': '50rem',
31 | '5xl': '66rem',
32 | },
33 | opacity: {
34 | 1: '0.01',
35 | 2.5: '0.025',
36 | 7.5: '0.075',
37 | 15: '0.15',
38 | },
39 | keyframes: {
40 | accordionDown: {
41 | from: { height: 0 },
42 | to: { height: "var(--radix-accordion-content-height)" },
43 | },
44 | accordionUp: {
45 | from: { height: "var(--radix-accordion-content-height)" },
46 | to: { height: 0 },
47 | },
48 | enterFromTop: {
49 | from: { opacity: 0, transform: 'translateY(-9px)' },
50 | to: { opacity: 1, transform: 'translateY(0)' },
51 | },
52 | enterFromRight: {
53 | from: { opacity: 0, transform: 'translateX(9px)' },
54 | to: { opacity: 1, transform: 'translateX(0)' },
55 | },
56 | enterFromBottom: {
57 | from: { opacity: 0, transform: 'translateX(9px)' },
58 | to: { opacity: 1, transform: 'translateX(0)' },
59 | },
60 | enterFromLeft: {
61 | from: { opacity: 0, transform: 'translateX(-9px)' },
62 | to: { opacity: 1, transform: 'translateX(0)' },
63 | },
64 | exitToTop: {
65 | from: { opacity: 1, transform: 'translateX(0)' },
66 | to: { opacity: 0, transform: 'translateX(-9px)' },
67 | },
68 | exitToRight: {
69 | from: { opacity: 1, transform: 'translateX(0)' },
70 | to: { opacity: 0, transform: 'translateX(9px)' },
71 | },
72 | exitToBottom: {
73 | from: { opacity: 1, transform: 'translateX(0)' },
74 | to: { opacity: 0, transform: 'translateY(9px)' },
75 | },
76 | exitToLeft: {
77 | from: { opacity: 1, transform: 'translateX(0)' },
78 | to: { opacity: 0, transform: 'translateX(-9px)' },
79 | },
80 | scaleIn: {
81 | from: { opacity: 0, transform: 'rotateX(-10deg) scale(0.9)' },
82 | to: { opacity: 1, transform: 'rotateX(0deg) scale(1)' },
83 | },
84 | scaleOut: {
85 | from: { opacity: 1, transform: 'rotateX(0deg) scale(1)' },
86 | to: { opacity: 0, transform: 'rotateX(-10deg) scale(0.95)' },
87 | },
88 | fadeIn: {
89 | from: { opacity: 0 },
90 | to: { opacity: 1 },
91 | },
92 | fadeOut: {
93 | from: { opacity: 1 },
94 | to: { opacity: 0 },
95 | },
96 | },
97 | },
98 | animation: {
99 | accordionDown: "accordionDown 120ms ease-out",
100 | accordionUp: "accordionUp 120ms ease-out",
101 | scaleIn: 'scaleIn 150ms ease',
102 | scaleOut: 'scaleOut 150ms ease',
103 | fadeIn: 'fadeIn 150ms ease',
104 | fadeOut: 'fadeOut 150ms ease',
105 | quickFadeIn: 'fadeIn 100ms ease',
106 | quickFadeOut: 'fadeOut 100ms ease',
107 | enterFromLeft: 'enterFromLeft 150ms ease-in-out',
108 | enterFromRight: 'enterFromRight 150ms ease-in-out',
109 | exitToLeft: 'exitToLeft 150ms ease-in-out',
110 | exitToRight: 'exitToRight 150ms ease-in-out',
111 | enterFromTop: 'enterFromTop 150ms ease-in-out',
112 | enterFromBottom: 'enterFromBottom 150ms ease-in-out',
113 | exitToTop: 'exitToTop 150ms ease-in-out',
114 | exitToBottom: 'exitToBottom 150ms ease-in-out',
115 | },
116 | },
117 | plugins: [require('@tailwindcss/typography')],
118 | }
119 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": ".",
4 | "paths": {
5 | "@/*": ["src/*"]
6 | },
7 | "target": "es5",
8 | "lib": [
9 | "dom",
10 | "dom.iterable",
11 | "esnext"
12 | ],
13 | "allowJs": true,
14 | "skipLibCheck": true,
15 | "strict": false,
16 | "forceConsistentCasingInFileNames": true,
17 | "noEmit": true,
18 | "incremental": true,
19 | "esModuleInterop": true,
20 | "module": "esnext",
21 | "moduleResolution": "node",
22 | "resolveJsonModule": true,
23 | "isolatedModules": true,
24 | "jsx": "preserve"
25 | },
26 | "include": [
27 | "next-env.d.ts",
28 | "**/*.ts",
29 | "**/*.tsx"
30 | ],
31 | "exclude": [
32 | "node_modules"
33 | ]
34 | }
35 |
--------------------------------------------------------------------------------