From c983324e4018c14004f3d81ad9b32d8cb570d919 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 4 Oct 2018 22:03:58 +0100 Subject: [PATCH] Functional -> function --- content/blog/2015-10-07-react-v0.14.md | 6 +++--- ...15-12-18-react-components-elements-and-instances.md | 6 +++--- content/blog/2016-04-07-react-v15.md | 2 +- content/blog/2016-07-13-mixins-considered-harmful.md | 4 ++-- content/blog/2017-04-07-react-v15.5.0.md | 2 +- content/blog/2018-03-29-react-v-16-3.md | 2 +- .../2018-06-07-you-probably-dont-need-derived-state.md | 2 +- content/docs/components-and-props.md | 8 ++++---- content/docs/forwarding-refs.md | 2 +- content/docs/higher-order-components.md | 4 ++-- content/docs/implementation-notes.md | 2 +- content/docs/legacy-context.md | 4 ++-- content/docs/reference-react-dom.md | 2 +- content/docs/reference-test-renderer.md | 4 ++-- content/docs/refs-and-the-dom.md | 10 +++++----- content/docs/state-and-lifecycle.md | 2 +- content/tutorial/nav.yml | 6 +++--- content/tutorial/tutorial.md | 8 ++++---- content/warnings/refs-must-have-owner.md | 6 +++--- 19 files changed, 41 insertions(+), 41 deletions(-) diff --git a/content/blog/2015-10-07-react-v0.14.md b/content/blog/2015-10-07-react-v0.14.md index f26e963ad97..3db41a7ad94 100644 --- a/content/blog/2015-10-07-react-v0.14.md +++ b/content/blog/2015-10-07-react-v0.14.md @@ -104,12 +104,12 @@ If you can’t use `npm` yet, we provide pre-built browser builds for your conve With this change, we’re deprecating `.getDOMNode()` and replacing it with `ReactDOM.findDOMNode` (see below). If your components are currently using `.getDOMNode()`, they will continue to work with a warning until 0.15. -- #### Stateless functional components +- #### Stateless function components In idiomatic React code, most of the components you write will be stateless, simply composing other components. We’re introducing a new, simpler syntax for these components where you can take `props` as an argument and return the element you want to render: ```js - // A functional component using an ES2015 (ES6) arrow function: + // A function component using an ES2015 (ES6) arrow function: var Aquarium = (props) => { var fish = getFish(props.species); return {fish}; @@ -125,7 +125,7 @@ If you can’t use `npm` yet, we provide pre-built browser builds for your conve // Then use: ``` - These components behave just like a React class with only a `render` method defined. Since no component instance is created for a functional component, any `ref` added to one will evaluate to `null`. Functional components do not have lifecycle methods, but you can set `.propTypes` and `.defaultProps` as properties on the function. + These components behave just like a React class with only a `render` method defined. Since no component instance is created for a function component, any `ref` added to one will evaluate to `null`. Function components do not have lifecycle methods, but you can set `.propTypes` and `.defaultProps` as properties on the function. This pattern is designed to encourage the creation of these simple components that should comprise large portions of your apps. In the future, we’ll also be able to make performance optimizations specific to these components by avoiding unnecessary checks and memory allocations. diff --git a/content/blog/2015-12-18-react-components-elements-and-instances.md b/content/blog/2015-12-18-react-components-elements-and-instances.md index e2b34b5ae8d..45e7ed217be 100644 --- a/content/blog/2015-12-18-react-components-elements-and-instances.md +++ b/content/blog/2015-12-18-react-components-elements-and-instances.md @@ -294,9 +294,9 @@ class Button extends React.Component { } ``` -When a component is defined as a class, it is a little bit more powerful than a functional component. It can store some local state and perform custom logic when the corresponding DOM node is created or destroyed. +When a component is defined as a class, it is a little bit more powerful than a function component. It can store some local state and perform custom logic when the corresponding DOM node is created or destroyed. -A functional component is less powerful but is simpler, and acts like a class component with just a single `render()` method. Unless you need features available only in a class, we encourage you to use functional components instead. +A function component is less powerful but is simpler, and acts like a class component with just a single `render()` method. Unless you need features available only in a class, we encourage you to use function components instead. **However, whether functions or classes, fundamentally they are all components to React. They take the props as their input, and return the elements as their output.** @@ -370,7 +370,7 @@ When a component receives some props as an input, it is because a particular par An *instance* is what you refer to as `this` in the component class you write. It is useful for [storing local state and reacting to the lifecycle events](/docs/component-api.html). -Functional components don’t have instances at all. Class components have instances, but you never need to create a component instance directly—React takes care of this. +Function components don’t have instances at all. Class components have instances, but you never need to create a component instance directly—React takes care of this. Finally, to create elements, use [`React.createElement()`](/docs/top-level-api.html#react.createelement), [JSX](/docs/jsx-in-depth.html), or an [element factory helper](/docs/top-level-api.html#react.createfactory). Don’t write elements as plain objects in the real code—just know that they are plain objects under the hood. diff --git a/content/blog/2016-04-07-react-v15.md b/content/blog/2016-04-07-react-v15.md index 5856d2b98b9..1731d11a007 100644 --- a/content/blog/2016-04-07-react-v15.md +++ b/content/blog/2016-04-07-react-v15.md @@ -71,7 +71,7 @@ If you can’t use `npm` yet, we provide pre-built browser builds for your conve [@sophiebits](https://github.com/sophiebits) in [#5451](https://github.com/facebook/react/pull/5451) -- #### Functional components can now return `null` too +- #### Function components can now return `null` too We added support for [defining stateless components as functions](/blog/2015/09/10/react-v0.14-rc1.html#stateless-function-components) in React 0.14. However, React 0.14 still allowed you to define a class component without extending `React.Component` or using `React.createClass()`, so [we couldn’t reliably tell if your component is a function or a class](https://github.com/facebook/react/issues/5355), and did not allow returning `null` from it. This issue is solved in React 15, and you can now return `null` from any component, whether it is a class or a function. diff --git a/content/blog/2016-07-13-mixins-considered-harmful.md b/content/blog/2016-07-13-mixins-considered-harmful.md index 81317a48849..389cddd2b63 100644 --- a/content/blog/2016-07-13-mixins-considered-harmful.md +++ b/content/blog/2016-07-13-mixins-considered-harmful.md @@ -373,7 +373,7 @@ function withSubscription(WrappedComponent) { }); } -// Optional change: convert CommentList to a functional component +// Optional change: convert CommentList to a function component // because it doesn't use lifecycle hooks or state. function CommentList(props) { var comments = props.comments; @@ -467,7 +467,7 @@ Props keep component dependencies explicit, easy to replace, and enforceable wit > **Note:** > -> Defining components as functions is not required. There is also nothing wrong with using lifecycle hooks and state—they are first-class React features. We use functional components in this example because they are easier to read and we didn’t need those extra features, but classes would work just as fine. +> Defining components as functions is not required. There is also nothing wrong with using lifecycle hooks and state—they are first-class React features. We use function components in this example because they are easier to read and we didn’t need those extra features, but classes would work just as fine. ### Context diff --git a/content/blog/2017-04-07-react-v15.5.0.md b/content/blog/2017-04-07-react-v15.5.0.md index a0654165620..9446f0e8346 100644 --- a/content/blog/2017-04-07-react-v15.5.0.md +++ b/content/blog/2017-04-07-react-v15.5.0.md @@ -69,7 +69,7 @@ You may also consider using [Flow](https://flow.org/) to statically type check y When React was initially released, there was no idiomatic way to create classes in JavaScript, so we provided our own: `React.createClass`. -Later, classes were added to the language as part of ES2015, so we added the ability to create React components using JavaScript classes. **Along with functional components, JavaScript classes are now the [preferred way to create components in React](/docs/components-and-props.html#functional-and-class-components).** +Later, classes were added to the language as part of ES2015, so we added the ability to create React components using JavaScript classes. **Along with function components, JavaScript classes are now the [preferred way to create components in React](/docs/components-and-props.html#functional-and-class-components).** For your existing `createClass` components, we recommend that you migrate them to JavaScript classes. However, if you have components that rely on mixins, converting to classes may not be immediately feasible. If so, `create-react-class` is available on npm as a drop-in replacement: diff --git a/content/blog/2018-03-29-react-v-16-3.md b/content/blog/2018-03-29-react-v-16-3.md index 6624f39d008..23ea0f54a5f 100644 --- a/content/blog/2018-03-29-react-v-16-3.md +++ b/content/blog/2018-03-29-react-v-16-3.md @@ -41,7 +41,7 @@ Version 16.3 adds a new option for managing refs that offers the convenience of Generally, React components are declarative, but sometimes imperative access to the component instances and the underlying DOM nodes is necessary. This is common for use cases like managing focus, selection, or animations. React provides [refs](/docs/refs-and-the-dom.html) as a way to solve this problem. However, component encapsulation poses some challenges with refs. -For example, if you replace a `