You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ux.symfony.com/cookbook/component_architecture.md
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ published_at: '2024-08-02'
14
14
In Symfony UX exist two packages: [TwigComponents](https://symfony.com/bundles/ux-twig-component/current/index.html) and [LiveComponent](https://symfony.com/bundles/ux-live-component/current/index.html).
15
15
Those two packages allow you to create reusable components in your Symfony application.
16
16
But the component architecture is not exclusive to Symfony, it's a design pattern that can be applied to any programming language or framework.
17
-
And the js world already implement this architecture for long time, on many different frameworks like React, Vue, or Svelte.
17
+
And the Javascript world already implements this architecture for long time, on many different frameworks like React, Vue, or Svelte.
18
18
So, a set of rules and pattern has already be defined to work with components. This is why Symfony UX try to be as close as possible to those rules.
19
19
So let's see what are those rules!
20
20
@@ -52,18 +52,18 @@ Or you can make composition with the following syntax:
52
52
</twig:Card>
53
53
```
54
54
55
-
So here we Card component, and we give to the content of this component two others components.
55
+
So here we have a Card component, and we give to the content of this component two others components.
56
56
57
57
### Independence
58
58
59
59
This is a really important rule, and not obvious. But your component should leave on his own context,
60
-
he should not be aware of the rest of the page. You should be able to take one component into a page, to another and it should work exactly the same.
60
+
it should not be aware of the rest of the page. You should be able to take one component into a page, to another and it should works exactly the same.
61
61
This rule make your component truly reusable.
62
62
63
63
***How does it work into Symfony?***
64
64
65
-
Symfony keep the context of the page into the context of your component. So this your own responsibility to follow this rules.
66
-
But notice that if there are conflict between a variable from the context page and your component, your component context override the page context.
65
+
Symfony keeps the context of the page into the context of your component. So this your own responsibility to follow those rules.
66
+
But notice that if there are conflicts between a variable from the context page and your component, your component context override the page context.
67
67
68
68
### Props
69
69
@@ -119,7 +119,7 @@ And when the loading is done, the state `loading` can be set to `false` and the
119
119
120
120
***How does it work into Symfony?***
121
121
122
-
In Symfony you 2 different approach to handle state. The first one is to use stimulus directly
122
+
In Symfony you have two different approaches to handle state. The first one is to use stimulus directly
123
123
in to your component. What we recommend to do is to set a controller stimulus at the root of your component.
0 commit comments