mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-24 04:33:10 +00:00
Merge pull request #3168 from briankung/docs-jsx-namespacing
[Docs] Clarify section on namespaced components
This commit is contained in:
@@ -89,9 +89,10 @@ If you want to use JSX, the [Getting Started](/react/docs/getting-started.html)
|
||||
|
||||
## Namespaced Components
|
||||
|
||||
If you are building a component that has many children, or if you are building your application with some categories of reusable components (like a `Form` category), to make it simpler and easier, you can use a *namespaced component* to avoid something like this:
|
||||
If you are building a component that has many children, like a form, you might end up with something with a lot of variable declarations:
|
||||
|
||||
```javascript
|
||||
// Awkward block of variable declarations
|
||||
var Form = MyFormComponent;
|
||||
var FormRow = Form.Row;
|
||||
var FormLabel = Form.Label;
|
||||
@@ -107,7 +108,7 @@ var App = (
|
||||
);
|
||||
```
|
||||
|
||||
Instead of declaring a bunch of variables at the top, you'll get just one component that has other components as attributes.
|
||||
To make it simpler and easier, *namespaced components* let you use one component that has other components as attributes:
|
||||
|
||||
```javascript
|
||||
var Form = MyFormComponent;
|
||||
|
||||
Reference in New Issue
Block a user