-
Notifications
You must be signed in to change notification settings - Fork 46.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[new docs] initial draft of glossary docs #8199
Conversation
Hey, sorry about the long time for review. For example, the JSX paragraph can have something like "To get familiar with JSX, read [Intro to JSX]. You can also read [JSX in Depth] to learn more about it." Same for other topics. |
Ok! What about the list of terms? Is there anything I should add? |
docs/docs/reference-glossary.md
Outdated
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. 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). Component names should also always start with a capital letter (`<Wrapper/>` **not** `<wrapper/>`) | ||
|
||
|
||
### `props` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's say just "Props" in the header. Same for "Children" and "State".
Looks good for the first pass. I think it would be great to add "bundler", "compiler", etc—all the terms people might see on other doc pages. Think somebody who never wrote any JavaScript: which words would they be confused about as they read through our docs? |
Ok! Gives me a good excuse to thoroughly read through the docs! :) |
… of github.com:facebook/react
So sorry for the delay! I've added more terms and included links to relevant documentation where necessary. Check it out @gaearon when you get a chance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking really good, added some feedback!
docs/docs/reference-glossary.md
Outdated
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/Transpilers | ||
A JavaScript compiler (or transpiler) 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's too pedantic to matter, but technically only transpilers, a subset of compilers, take source code and return source code. Maybe we can clarify this, something like:
A JavaScript transpiler is a compiler that takes JavaScript code, transforms it, and returns JavaScript code in a different format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok yeah -- I'm still a little fuzzy on the difference between transpilers and compilers -- some of the articles I read about it said the words were interchangeable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah its kind of a tricky topic. A compiler is a general term for any program that takes source code in, and outputs some other representation of that code. Usually, compilers will compile code from a source language (like JavaScript) to a lower level target language (like machine code).
A transpiler is a special kind of compiler that takes in one type of source code and outputs another type of source code. So babel is a transpiler since it takes in JavaScript and outputs JavaScript
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were trying to avoid saying "transpiler" in new docs because it confuses everyone. Let's just always say "compiler" and ignore the "transpiler" term. Even Babel docs don't use it.
docs/docs/reference-glossary.md
Outdated
A JavaScript compiler (or transpiler) 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 & Browserify |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets just use "and" instead of "&" throughout the doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, missing period at the end.
docs/docs/reference-glossary.md
Outdated
Bundlers put all of your JavaScript code & dependency into one "bundle", usually into one file. Some bundlers commonly used in React applications include: Webpack & 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing period at the end.
docs/docs/reference-glossary.md
Outdated
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. When JSX gets compiled, the result is JavaScript objects called "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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When JSX gets compiled, the result is JavaScript objects called "elements".
JSX doesn't get compiled directly to objects. It is typically compiled to function calls that return those objects. In React its compiled to React.createElement
calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the "intro to JSX" documentation be modified? In this section: https://facebook.github.io/react/docs/introducing-jsx.html#jsx-is-an-expression-too it says "After compilation, JSX expressions become regular JavaScript objects."
For the glossary, I can change the phrasing to say something like "JSX gets compiled to React.createElement()
calls which return plain JavaScript objects called 'React elements'." <-- Does that feel like a better description? I was trying to keep the definitions simple and refer people to the actual documentation if they wanted to dig a little deeper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we should probably update that section as its misleading. You can see here that JSX gets compiled to React.createElement
calls that return objects called "elements".
Does that feel like a better description?
That definitely sounds better 👍
docs/docs/reference-glossary.md
Outdated
## JSX | ||
JSX is a syntax extension to JavaScript. It is similar to a template language. When JSX gets compiled, the result is JavaScript objects called "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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be helpful to clarify that we use the JavaScript API naming conventions specifically.
docs/docs/reference-glossary.md
Outdated
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after third sentence.
`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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For function components, it would just be props.children
, since you access it on the passed parameter and not this
docs/docs/reference-glossary.md
Outdated
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. When the ref attribute is used on an HTML element, the ref callback receives the underlying DOM element as its argument. This allows you to have direct access to the DOM element |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refs can be functions or strings (string refs are pretty-much-legacy but still allowed). Also, missing a period at the end.
docs/docs/reference-glossary.md
Outdated
* With JSX you pass a function as the event handler, rather than a string. | ||
|
||
|
||
## Reconciliation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's link to the reconcilliation doc page here: https://facebook.github.io/react/docs/reconciliation.html
@aweary Thanks for jumping on this! |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A component's
state
is a snapshot of the data contained in a component.
I'm worried this might sound misleading; someone might think state is a periodical snapshot of the props
passed in or something. Maybe rephrase to something like:
State is a way for components to manage data that is private and fully controlled by that component.
That's also closer to what we say in the linked docs page.
state
is user-defined,props
are received from a parent component.
props
are technically user-defined too, just defined in another component 😄 It may be more accurate to say:
state
is owned and controlled by the component that created it.props
are received from a parent component.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A "key" is a special string attribute you need to include when creating lists of elements.
I don't think there's any specific restriction that says a key has to be a string. It's the most common thing to use, but you could also use numbers, or even objects.
@mrscobbler is this still being actively developed? |
yes, I've made some of the changes but haven't had a chance to push them to github. Is this something you're interested in collaborating on? |
yeah! would love to help out! 😄 |
Thank you for submitting this PR! 😄 Unfortunately the documentation and source code for reactjs.org has been moved to a different repository: https://github.com/reactjs/reactjs.org I realize this PR is old and there may no longer be interest in seeing it merged. If there is, please open a new PR there. Sorry for the inconvenience! (For more backstory on why we moved to a new repo, see issue #11075) |
Would love some feedback on these terms -- let me know if there are other terms that should be added.