@@ -62,7 +62,7 @@ Finally, to load your React components, add the following lines to ``assets/app.
62
62
// they are not necessary.
63
63
registerReactControllerComponents (require .context (' ./react/controllers' , true , / \. (j| t)sx? $ / ));
64
64
65
- That's it! Create an `assets/react/controllers/ ` directory and start creating your
65
+ That's it! Create an `` assets/react/controllers/ ` ` directory and start creating your
66
66
React components.
67
67
68
68
Usage
@@ -77,6 +77,7 @@ React components located in the directory ``assets/react/controllers`` are regis
77
77
React controller components.
78
78
79
79
You can then render any React controller component in Twig using the ``react_component ``.
80
+
80
81
For example:
81
82
82
83
.. code-block :: javascript
@@ -88,11 +89,19 @@ For example:
88
89
return < div> Hello {props .fullName }< / div> ;
89
90
}
90
91
91
-
92
92
.. code-block :: html+twig
93
93
94
94
{# templates/home.html.twig #}
95
- <div {{ react_component('MyComponent', { 'fullName': app.user.fullName }) }}></div>
95
+ {% extends 'base.html.twig' %}
96
+
97
+ {% block body %}
98
+ <div {{ react_component('MyComponent', { 'fullName': number }) }}>
99
+ Loading... <i class="fas fa-cog fa-spin fa-3x"></i>
100
+ </div>
101
+
102
+ {# Component living in a subdirectory: "assets/react/controllers/Admin/OtherComponent" #}
103
+ <div {{ react_component('Admin/OtherComponent') }}></div>
104
+ {% endblock %}
96
105
97
106
Backward Compatibility promise
98
107
------------------------------
0 commit comments