Browse Source

Merge pull request #3168 from briankung/docs-jsx-namespacing

[Docs] Clarify section on namespaced components
main
Paul O’Shannessy 10 years ago
parent
commit
37bed2afeb
  1. 5
      docs/02.1-jsx-in-depth.md

5
docs/02.1-jsx-in-depth.md

@ -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;

Loading…
Cancel
Save