-
-
Notifications
You must be signed in to change notification settings - Fork 1
Compose bigger components using smaller components
Vetrivel edited this page Jan 24, 2020
·
4 revisions
Components can be composed together to build bigger components. Here is how.
- Reload
-
Type
ContainerComponent
inEditor panel -> Component name field
. -
Type
<div className="fixed"></div>
inEditor panel -> Component markup field
. -
Type
.fixed{height:200px; width: 200px; background-color:brown;}
inEditor panel -> Component CSS field
. -
Click
Editor panel -> Save button
. -
Click
Components panel -> ContainerComponent
. You should see the preview panel rendering a brown rectangle.
- Reload.
-
Type
SubComponent
inEditor Panel -> Component name field
. -
Type
<h4>Hello</h4>
inEditor Panel -> Component markup field
. -
Click
Editor panel -> Save button
. - Reload.
-
Click
Components panel -> SubComponent
. You should see the preview pane rendering "Hello".
- Reload.
-
Click
Components panel -> ContainerComponent
. In Preview panel, you should see a brown rectangle. -
Click
Preview panel -> Drop button
. -
Drag
Editor panel -> SubComponent
and drop it onPreview Panel -> Brown rectangle
. While dragging over, you should see a green border around the brown rectangle. -
Release mouse. You should see
Hello
inside the brown box. This means drag and dropping the component was successful. -
Click
Preview panel -> Drop button
. -
Drag
Editor panel -> HelloWorldComponent
and Drop it onPreview Panel -> Brown box
. While dragging over, you should see a green border around the brown rectangle. You should seeHello world
with green border visible. This is another successful drop. - Reload
-
Click
Components panel -> ContainerComponent
. If you look atEditor panel -> Component markup
, you can see the reference to child components are updated. -
Click "Hello World". You should see
Hi world
with red border just as if it was an independent component. This shows that while composing components, the child component will retain its behaviour as it was created.
- Reload.
-
Click
Components panel -> ContainerComponent
. In Preview panel, you should see a brown rectangle. -
Edit
Editor panel -> Component markup field
. Add<SubComponent></SubComponent>
and<HelloWorldComponent></HelloWorldComponent>
wherever you would like to have. -
Click
Editor panel -> Save button
. - Reload
-
Click
Components panel -> ContainerComponent
. In Preview panel, you should see child components rendered.
Sidebar