Skip to content

Commit f3b89a5

Browse files
committed
Rewording, added notes and warnings
1 parent 0adbb66 commit f3b89a5

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/LiveComponent/doc/index.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2333,6 +2333,15 @@ component, for example: ``https://my.domain/search?query=my+search+string``.
23332333
Then, if you load this URL in your browser, your component will be initialized with the values provided in the query
23342334
string.
23352335

2336+
.. note::
2337+
2338+
URL is updated in place, no new entry is added to the browser's history.
2339+
2340+
.. warning::
2341+
2342+
You can use multiple components with URL bindings in the same page, as long as bound field names don't collide.
2343+
Otherwise, you will observe unexpected behaviors.
2344+
23362345
Supported data types
23372346
~~~~~~~~~~~~~~~~~~~~
23382347

@@ -2357,7 +2366,7 @@ Multiple bindings
23572366
~~~~~~~~~~~~~~~~~
23582367

23592368
You can use as many URL bindings as you want in your component. To ensure the state is fully represented in the URL,
2360-
all bound props will be added to query parameters, even if their values didn't change.
2369+
all bound props will be set as query parameters, even if their values didn't change.
23612370

23622371
For example, if you declare the following bindings::
23632372

@@ -2380,6 +2389,11 @@ And you only set the ``query`` value, then your URL will be updated to ``https:/
23802389
Validation
23812390
~~~~~~~~~~
23822391

2392+
.. caution::
2393+
2394+
It is recommended to validate data provided through query string parameters, so you can prevent malicious inputs
2395+
from being processed and rendered.
2396+
23832397
To validate your component state when it is rendered for the first time, you have to setup a `PostMount hook`_::
23842398

23852399
// ...
@@ -2409,6 +2423,9 @@ To validate your component state when it is rendered for the first time, you hav
24092423
// ...
24102424
}
24112425

2426+
.. note::
2427+
2428+
You can use `validation groups`_ if you want to use specific validation rules only in the PostMount hook.
24122429

24132430
.. _emit:
24142431

@@ -3424,3 +3441,4 @@ bound to Symfony's BC policy for the moment.
34243441
.. _`pass content to Twig Components`: https://symfony.com/bundles/ux-twig-component/current/index.html#passing-blocks
34253442
.. _`Twig Component debug command`: https://symfony.com/bundles/ux-twig-component/current/index.html#debugging-components
34263443
.. _`PostMount hook`: https://symfony.com/bundles/ux-twig-component/current/index.html#postmount-hook
3444+
.. _`validation groups`: https://symfony.com/doc/current/form/validation_groups.html

0 commit comments

Comments
 (0)