From 37feb36a061d8be3063d9cb1fa5fc30691444217 Mon Sep 17 00:00:00 2001 From: Sophia Shoemaker Date: Thu, 12 Oct 2017 16:02:08 -0700 Subject: [PATCH 1/3] adding glossary content --- content/docs/nav.yml | 2 + content/docs/reference-glossary.md | 98 ++++++++++++++++++++++++++++++ content/docs/reference-react.md | 1 - 3 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 content/docs/reference-glossary.md diff --git a/content/docs/nav.yml b/content/docs/nav.yml index 61f14a44..7b385b3d 100644 --- a/content/docs/nav.yml +++ b/content/docs/nav.yml @@ -81,6 +81,8 @@ title: Test Renderer - id: javascript-environment-requirements title: JS Environment Requirements + - id: glossary + title: Glossary - title: Contributing items: - id: how-to-contribute diff --git a/content/docs/reference-glossary.md b/content/docs/reference-glossary.md new file mode 100644 index 00000000..1c29327b --- /dev/null +++ b/content/docs/reference-glossary.md @@ -0,0 +1,98 @@ +--- +id: glossary +title: Glossary of React Terms +layout: docs +category: Reference +permalink: docs/glossary.html + +--- + +## Single Page Application +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. + + +## ES6/ES2015 + ES6 AKA ES2015 is the current version 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, and `let` and `const` statements. + +## Compilers +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 browsers are capable of interpreting. Babel is the compiler used with React. + +## Bundlers +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. + +## Package Manager +Package managers are tools that allow you to manage dependencies in your project. npm & Yarn are two package managers commonly used in React applications. + +## CDN +CDN stands for Content Delivery Network. CDNs deliver cached, static content from a network of servers across the globe. + +## JSX +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](https://facebook.github.io/react/docs/introducing-jsx.html) and find a more in-depth tutorial on JSX [here](https://facebook.github.io/react/docs/jsx-in-depth.html) + +React DOM uses camelCase property naming convention instead of HTML attribute names. +For example, class becomes className in JSX, and tabindex becomes tabIndex. + +## [Elements](https://facebook.github.io/react/docs/rendering-elements.html) +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. + +```js +const element =

Hello, world

; +``` + +## [Components](https://facebook.github.io/react/docs/components-and-props.html) +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: + +```js +function Welcome(props) { + return

Hello, {props.name}

; +} +``` + +Components can also be ES6 classes: + +```js +class Welcome extends React.Component { + render() { + return

Hello, {this.props.name}

; + } +} +``` + +Components can be broken down into distinct pieces of functionality and used within other components. Components must return a single root element (wrapped in a `div` or other similar container). 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 (`` **not** ``). + + +### [`props`](https://facebook.github.io/react/docs/components-and-props.html) +`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`. + +### `this.props.children` +`this.props.children` is available on every component. It contains the content between the opening and closing tags of a component. For example: + +```js +Hello world! +``` +The string `Hello world!` is available in `this.props.children` in the `Welcome` component. + +### [`state`](https://facebook.github.io/react/docs/state-and-lifecycle.html#adding-local-state-to-a-class) +A component's `state` is a snapshot of the data contained in a component. `props` and `state` are different: `state` is user-defined, `props` are received from a parent component. + +## [Lifecycle Methods](https://facebook.github.io/react/docs/state-and-lifecycle.html#adding-lifecycle-methods-to-a-class) +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](https://facebook.github.io/react/docs/react-component.html#mounting)), when the component updates and when the component gets unmounted or removed from the DOM. + + ## [Controlled](https://facebook.github.io/react/docs/forms.html#controlled-components) vs. [Uncontrolled Components](https://facebook.github.io/react/docs/uncontrolled-components.html) +React has two different approaches to dealing with form inputs. An input form element whose value is controlled by React is called a *controlled component*. An *uncontrolled component* is an input that is just like any normal input we would use outside of React. When a user inputs data into a form field (an input box, dropdown, etc) the updated information is reflected. + +## [Keys](https://facebook.github.io/react/docs/lists-and-keys.html) + A "key" is a special string attribute you need to include when creating lists 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. + +## [Refs](https://facebook.github.io/react/docs/refs-and-the-dom.html) +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 as its argument. This allows you to have direct access to the DOM element. + +## [Events](https://facebook.github.io/react/docs/handling-events.html) +Handling events with React elements has some syntactic differences: + +* React events are named using camelCase, rather than lowercase. +* With JSX you pass a function as the event handler, rather than a string. + + +## [Reconciliation](https://facebook.github.io/react/docs/reconciliation.html) +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` \ No newline at end of file diff --git a/content/docs/reference-react.md b/content/docs/reference-react.md index 95a0ab49..6cdcf3b7 100644 --- a/content/docs/reference-react.md +++ b/content/docs/reference-react.md @@ -11,7 +11,6 @@ redirect_from: - "docs/top-level-api-ja-JP.html" - "docs/top-level-api-ko-KR.html" - "docs/top-level-api-zh-CN.html" - - "docs/glossary.html" --- `React` is the entry point to the React library. If you load React from a `