diff --git a/README.md b/README.md index 966131db576..9b11287efd5 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ The documentation is divided into several sections with a different tone and pur 1. Follow the ["Running locally"](#running-locally) instructions 1. Save the files and check in the browser - 1. Changes to React components in `src` will hot-reload + 1. Changes to React Components in `src` will hot-reload 1. Changes to markdown files in `content` will hot-reload 1. If working with plugins, you may need to remove the `.cache` directory and restart the server diff --git a/src/components/Seo.tsx b/src/components/Seo.tsx index dfc4f61049d..210a67603b5 100644 --- a/src/components/Seo.tsx +++ b/src/components/Seo.tsx @@ -55,7 +55,7 @@ export const Seo = withRouter( // Twitter's meta parser is not very good. const twitterTitle = pageTitle.replace(/[<>]/g, ''); let description = isHomePage - ? 'React is the library for web and native user interfaces. Build user interfaces out of individual pieces called components written in JavaScript. React is designed to let you seamlessly combine components written by independent people, teams, and organizations.' + ? 'React is the library for web and native user interfaces. Build user interfaces out of individual pieces called Components written in JavaScript. React is designed to let you seamlessly combine Components written by independent people, teams, and organizations.' : 'The library for web and native user interfaces'; return ( diff --git a/src/content/learn/add-react-to-an-existing-project.md b/src/content/learn/add-react-to-an-existing-project.md index f494b0ab1e9..33cb708d151 100644 --- a/src/content/learn/add-react-to-an-existing-project.md +++ b/src/content/learn/add-react-to-an-existing-project.md @@ -4,7 +4,7 @@ title: Add React to an Existing Project -If you want to add some interactivity to your existing project, you don't have to rewrite it in React. Add React to your existing stack, and render interactive React components anywhere. +If you want to add some interactivity to your existing project, you don't have to rewrite it in React. Add React to your existing stack, and render interactive React Components anywhere. @@ -30,18 +30,18 @@ Many React-based frameworks are full-stack and let your React app take advantage ## Using React for a part of your existing page {/*using-react-for-a-part-of-your-existing-page*/} -Let's say you have an existing page built with another technology (either a server one like Rails, or a client one like Backbone), and you want to render interactive React components somewhere on that page. That's a common way to integrate React--in fact, it's how most React usage looked at Meta for many years! +Let's say you have an existing page built with another technology (either a server one like Rails, or a client one like Backbone), and you want to render interactive React Components somewhere on that page. That's a common way to integrate React--in fact, it's how most React usage looked at Meta for many years! You can do this in two steps: 1. **Set up a JavaScript environment** that lets you use the [JSX syntax](/learn/writing-markup-with-jsx), split your code into modules with the [`import`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) / [`export`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export) syntax, and use packages (for example, React) from the [npm](https://www.npmjs.com/) package registry. -2. **Render your React components** where you want to see them on the page. +2. **Render your React Components** where you want to see them on the page. The exact approach depends on your existing page setup, so let's walk through some details. ### Step 1: Set up a modular JavaScript environment {/*step-1-set-up-a-modular-javascript-environment*/} -A modular JavaScript environment lets you write your React components in individual files, as opposed to writing all of your code in a single file. It also lets you use all the wonderful packages published by other developers on the [npm](https://www.npmjs.com/) registry--including React itself! How you do this depends on your existing setup: +A modular JavaScript environment lets you write your React Components in individual files, as opposed to writing all of your code in a single file. It also lets you use all the wonderful packages published by other developers on the [npm](https://www.npmjs.com/) registry--including React itself! How you do this depends on your existing setup: * **If your app is already split into files that use `import` statements,** try to use the setup you already have. Check whether writing `
` in your JS code causes a syntax error. If it causes a syntax error, you might need to [transform your JavaScript code with Babel](https://babeljs.io/setup), and enable the [Babel React preset](https://babeljs.io/docs/babel-preset-react) to use JSX. @@ -73,7 +73,7 @@ import { createRoot } from 'react-dom/client'; // Clear the existing HTML content document.body.innerHTML = '
'; -// Render your React component instead +// Render your React Component instead const root = createRoot(document.getElementById('app')); root.render(

Hello, world

); ``` @@ -88,7 +88,7 @@ Integrating a modular JavaScript environment into an existing project for the fi -### Step 2: Render React components anywhere on the page {/*step-2-render-react-components-anywhere-on-the-page*/} +### Step 2: Render React Components anywhere on the page {/*step-2-render-react-components-anywhere-on-the-page*/} In the previous step, you put this code at the top of your main file: @@ -98,7 +98,7 @@ import { createRoot } from 'react-dom/client'; // Clear the existing HTML content document.body.innerHTML = '
'; -// Render your React component instead +// Render your React Component instead const root = createRoot(document.getElementById('app')); root.render(

Hello, world

); ``` @@ -107,7 +107,7 @@ Of course, you don't actually want to clear the existing HTML content! Delete this code. -Instead, you probably want to render your React components in specific places in your HTML. Open your HTML page (or the server templates that generate it) and add a unique [`id`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id) attribute to any tag, for example: +Instead, you probably want to render your React Components in specific places in your HTML. Open your HTML page (or the server templates that generate it) and add a unique [`id`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id) attribute to any tag, for example: ```html @@ -115,7 +115,7 @@ Instead, you probably want to render your React components in specific places in ``` -This lets you find that HTML element with [`document.getElementById`](https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById) and pass it to [`createRoot`](/reference/react-dom/client/createRoot) so that you can render your own React component inside: +This lets you find that HTML element with [`document.getElementById`](https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById) and pass it to [`createRoot`](/reference/react-dom/client/createRoot) so that you can render your own React Component inside: @@ -146,7 +146,7 @@ root.render(); -Notice how the original HTML content from `index.html` is preserved, but your own `NavigationBar` React component now appears inside the `