Skip to content

Commit 4b4d307

Browse files
authored
Tweak glossay
1 parent 3bcc1f5 commit 4b4d307

1 file changed

Lines changed: 85 additions & 20 deletions

File tree

content/docs/reference-glossary.md

Lines changed: 85 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,58 @@ permalink: docs/glossary.html
77

88
---
99

10-
## Single Page Application
11-
A single page application is an application that loads a single HTML page and all the necessary assets (CSS, Images & JavaScript) required for the application to run. Any interactions with the page or subsequent pages do not require a round trip to the server which means the page is not reloaded.
10+
## Single-page Application
1211

12+
A single-page application is an application that loads a single HTML page and all the necessary assets (such as JavaScript and CSS) required for the application to run. Any interactions with the page or subsequent pages do not require a round trip to the server which means the page is not reloaded.
1313

14-
## ES6/ES2015/ES7/ES2016/ES8/ES2017
15-
These acronyms all refer to the most recent versions of the ECMAScript Language Specification standard, which the JavaScript language is an implementation of. It includes many additions to the previous versions such as: arrow functions, classes, template literals, `let` and `const` statements. You can learn more about specific versions [here](https://en.wikipedia.org/wiki/ECMAScript#Versions).
14+
Though you may build a single-page application in React, it is not a requirement. React can also be used for enhancing small parts of existing websites with additional interactivity. Code written in React can coexist peacefully with markup rendered on the server by something like PHP, or with other client-side libraries. In fact, it's exactly how React is being used at Facebook.
15+
16+
## ES6, ES2015, ES2016, etc
17+
18+
These acronyms all refer to the most recent versions of the ECMAScript Language Specification standard, which the JavaScript language is an implementation of. The ES6 version (also known as ES2015) includes many additions to the previous versions such as: arrow functions, classes, template literals, `let` and `const` statements. You can learn more about specific versions [here](https://en.wikipedia.org/wiki/ECMAScript#Versions).
1619

1720
## Compilers
18-
A JavaScript compiler takes JavaScript code, transforms it and returns JavaScript code in a different format. The most common use case is to take ES2015/ES6 syntax and transform it into syntax that older browsers are capable of interpreting. Babel is the compiler used with React.
21+
22+
A JavaScript compiler takes JavaScript code, transforms it and returns JavaScript code in a different format. The most common use case is to take ES6 syntax and transform it into syntax that older browsers are capable of interpreting. [Babel](https://babeljs.io/) is the compiler most commonly used with React.
1923

2024
## Bundlers
21-
Bundlers put all of your JavaScript code & dependency into one "bundle", usually into one file. Some bundlers commonly used in React applications include: Webpack and Browserify.
25+
26+
Bundlers take JavaScript and CSS code written as separate modules (often hundreds of them), and combine them together into a few files better optimized for the browsers. Some bundlers commonly used in React applications include [Webpack](https://webpack.js.org/) and [Browserify](http://browserify.org/).
2227

2328
## Package Manager
24-
Package managers are tools that allow you to manage dependencies in your project. npm & Yarn are two package managers commonly used in React applications.
29+
30+
Package managers are tools that allow you to manage dependencies in your project. [npm](https://www.npmjs.com/) and [Yarn](http://yarnpkg.com/) are two package managers commonly used in React applications. Both of them are clients for the same npm package registry.
2531

2632
## CDN
33+
2734
CDN stands for Content Delivery Network. CDNs deliver cached, static content from a network of servers across the globe.
2835

2936
## JSX
30-
JSX is a syntax extension to JavaScript. It is similar to a template language. JSX gets compiled to `React.createElement()` calls which return plain JavaScript objects called 'React elements'. To get a basic introduction to JSX [see the docs here](/docs/introducing-jsx.html) and find a more in-depth tutorial on JSX [here](/docs/jsx-in-depth.html)
3137

32-
React DOM uses camelCase property naming convention instead of HTML attribute names. For example, tabindex becomes tabIndex in JSX. The attribute class is also written as className since `class` is a reserved word in JavaScript.
38+
JSX is a syntax extension to JavaScript. It is similar to a template language, but it has full power of JavaScript. JSX gets compiled to `React.createElement()` calls which return plain JavaScript objects called "React elements". To get a basic introduction to JSX [see the docs here](/docs/introducing-jsx.html) and find a more in-depth tutorial on JSX [here](/docs/jsx-in-depth.html).
39+
40+
React DOM uses camelCase property naming convention instead of HTML attribute names. For example, `tabindex` becomes `tabIndex` in JSX. The attribute `class` is also written as `className` since `class` is a reserved word in JavaScript:
41+
42+
```js
43+
const name = 'Clementine';
44+
ReactDOM.render(
45+
<h1 className="hello">My name is {name}!</h1>,
46+
document.getElementById('root')
47+
);
48+
```
3349

3450
## [Elements](/docs/rendering-elements.html)
51+
3552
React elements are the building blocks of React applications. One might confuse elements with a more widely known concept of "components". Elements are what components are "made of". An element describes what you want to see on the screen. React elements are immutable.
3653

3754
```js
3855
const element = <h1>Hello, world</h1>;
3956
```
4057

58+
Typically, elements are not used directly, but get returned from components.
59+
4160
## [Components](/docs/components-and-props.html)
61+
4262
React components are small, resuable pieces of code that return a React element to be rendered to the page. The simplest version of React component is a plain JavaScript function that returns a React element:
4363

4464
```js
@@ -59,43 +79,88 @@ class Welcome extends React.Component {
5979

6080
Components can be broken down into distinct pieces of functionality and used within other components. Components can return other components, arrays, strings and numbers. A good rule of thumb is that if a part of your UI is used several times (Button, Panel, Avatar), or is complex enough on its own (App, FeedStory, Comment), it is a good candidate to be a reusable component. Component names should also always start with a capital letter (`<Wrapper/>` **not** `<wrapper/>`). See [this documentation](/docs/components-and-props.html#rendering-a-component) for more information on rendering components.
6181

62-
6382
### [`props`](/docs/components-and-props.html)
64-
`props` are inputs to a React component. They are data passed down from a parent component to a child component. `props` are readonly -- they should not be modified in any way. All React components must act like pure functions with respect to their `props`.
6583

66-
### `this.props.children`
67-
`this.props.children` is available on every component. It contains the content between the opening and closing tags of a component. For example:
84+
`props` are inputs to a React component. They are data passed down from a parent component to a child component.
85+
86+
Remember that `props` are readonly. They should not be modified in any way:
87+
88+
```js
89+
// Wrong!
90+
props.number = 42;
91+
```
92+
93+
If you need to modify some value in response to user input or a network response, use `state` instead.
94+
95+
### `props.children`
96+
97+
`props.children` is available on every component. It contains the content between the opening and closing tags of a component. For example:
6898

6999
```js
70100
<Welcome>Hello world!</Welcome>
71101
```
72-
The string `Hello world!` is available in `this.props.children` in the `Welcome` component.
102+
103+
The string `Hello world!` is available in `props.children` in the `Welcome` component:
104+
105+
```js
106+
function Welcome(props) {
107+
return <p>{props.children}</p>;
108+
}
109+
```
110+
111+
For components defined as classes, use `this.props.children`:
112+
113+
```js
114+
class Welcome extends React.Component {
115+
render() {
116+
return <p>{this.props.children}</p>;
117+
}
118+
}
119+
```
73120

74121
### [`state`](/docs/state-and-lifecycle.html#adding-local-state-to-a-class)
75-
A component's `state` is a snapshot of the data contained in a component. `props` and `state` are different: `props` are passed in from a parent component; `state` is managed within a component.
122+
123+
A component needs `state` when some data associated with it changes over time. For example, a `Checkbox` component might need `isChecked` in its state, and a `NewsFeed` component might want to keep track of `fetchedPosts` in its state.
124+
125+
The most important difference between `state` and `props` is that `props` are passed from a parent component, but `state` is managed by the component itself. A component cannot change its `props`, but it can change its `state`.
126+
127+
For each particular piece of changing data, there should be just one component that "owns" it in its state. Don't try to synchronize states of two different components. Instead, [lift it up](/docs/lifting-state-up.html) to their closest shared ancestor, and pass it down as props to both of them.
76128

77129
## [Lifecycle Methods](/docs/state-and-lifecycle.html#adding-lifecycle-methods-to-a-class)
78-
Lifecycle methods are custom functionality that gets executed during the different phases of a component. There are methods available when the component gets created and inserted into the DOM ([mounting](/docs/react-component.html#mounting)), when the component updates, and when the component gets unmounted or removed from the DOM.
130+
131+
Lifecycle methods are custom functionality that gets executed during the different phases of a component. There are methods available when the component gets created and inserted into the DOM ([mounting](/docs/react-component.html#mounting)), when the component updates, and when the component gets unmounted or removed from the DOM.
79132

80133
## [Controlled](/docs/forms.html#controlled-components) vs. [Uncontrolled Components](/docs/uncontrolled-components.html)
134+
81135
React has two different approaches to dealing with form inputs.
82136

83137
An input form element whose value is controlled by React is called a *controlled component*. When a user enters data into a controlled component a change event handler is triggered and your code decides whether the input is valid (by re-rendering with the updated value). If you do not re-render then the form element will remain unchanged.
84138

85-
An *uncontrolled component* works like form elements do outside of React. When a user inputs data into a form field (an input box, dropdown, etc) the updated information is reflected without React needing to do anything.
139+
An *uncontrolled component* works like form elements do outside of React. When a user inputs data into a form field (an input box, dropdown, etc) the updated information is reflected without React needing to do anything, but you can't force the field to have a certain value.
140+
141+
In most cases you should use controlled components.
86142

87143
## [Keys](/docs/lists-and-keys.html)
88-
A "key" is a special string attribute you need to include when creating arrays of elements. Keys help React identify which items have changed, are added, or are removed. Keys should be given to the elements inside an array to give the elements a stable identity.
144+
145+
A "key" is a special string attribute you need to include when creating arrays of elements. Keys help React identify which items have changed, are added, or are removed. Keys should be given to the elements inside an array to give the elements a stable identity.
146+
147+
Keys only need to be unique among sibling elements in the same array. They don't need to be unique across the whole application or even a single component.
148+
149+
Don't pass something like `Math.random()` to keys. It is important that keys have a "stable identity" across re-renders so that React can determine when items are added, removed, or re-ordered. Ideally, keys should correspond to unique and stable identifiers coming from your data, such as `post.id`.
89150

90151
## [Refs](/docs/refs-and-the-dom.html)
152+
91153
React supports a special attribute that you can attach to any component. The `ref` attribute can be a string or a callback function. When the `ref` attribute is a callback function, the function receives the underlying DOM element or class instance (depending on the type of element) as its argument. This allows you to have direct access to the DOM element or component instance.
92154

155+
Use refs sparingly. If you find yourself often using refs to "make things happen" in your app, consider getting more familiar with [top-down data flow](/docs/lifting-state-up.html).
156+
93157
## [Events](/docs/handling-events.html)
158+
94159
Handling events with React elements has some syntactic differences:
95160

96161
* React event handlers are named using camelCase, rather than lowercase.
97162
* With JSX you pass a function as the event handler, rather than a string.
98163

99-
100164
## [Reconciliation](/reconciliation.html)
101-
When a component's props or state change, React decides whether an actual DOM update is necessary by comparing the newly returned element with the previously rendered one. When they are not equal, React will update the DOM. This process is called `reconciliation`
165+
166+
When a component's props or state change, React decides whether an actual DOM update is necessary by comparing the newly returned element with the previously rendered one. When they are not equal, React will update the DOM. This process is called "reconciliation".

0 commit comments

Comments
 (0)