Skip to content

Commit 86d08cb

Browse files
committed
minor #2435 [LiveComponent] "Hooks: Handle Component Behavior" spacing issue in docs (nehalgajjar)
This PR was merged into the 2.x branch. Discussion ---------- [LiveComponent] "Hooks: Handle Component Behavior" spacing issue in docs | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Issues | Fix #2363 | License | MIT <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - For new features, provide some code snippets to help understand usage. - Features and deprecations must be submitted against branch main. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> ## [Issue] Fix Line Break / Spacing <img width="641" alt="image" src="https://github.com/user-attachments/assets/ee5336a2-fa1f-4f5d-a05d-5d561d5c5229"> Commits ------- f40f510 Fix [LiveComponent] "Hooks: Handle Component Behavior" spacing issue in docs
2 parents a59e390 + f40f510 commit 86d08cb

File tree

1 file changed

+49
-45
lines changed

1 file changed

+49
-45
lines changed

src/LiveComponent/doc/index.rst

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -181,51 +181,6 @@ let's keep going because… things get cooler.
181181
Need to do some extra data initialization on your component? Create
182182
a ``mount()`` method or use the ``PostMount`` hook: `Twig Component mount documentation`_.
183183

184-
Hooks: Handle Component Behavior
185-
--------------------------------
186-
Most of the time, you'll just pass data to your components and
187-
let it handle the rest. However, if you need to do something
188-
more complex during certain stages of a component's lifecycle, you
189-
can take advantage of lifecycle hooks.
190-
191-
``PostHydrate`` Hook
192-
~~~~~~~~~~~~~~~~~~~~
193-
The ``#[PostHydrate]`` hook is called immediately after the component's state
194-
is loaded from the client. This is useful if you need to process or adjust
195-
the data once it’s been hydrated.
196-
197-
``PreDehydrate`` Hook
198-
~~~~~~~~~~~~~~~~~~~~~
199-
The ``#[PreDehydrate]`` hook is triggered just before your component’s state
200-
is sent back to the client. You can use this to modify or clean up the data
201-
before it’s serialized and returned to the client.
202-
203-
``PreReRender`` Hook
204-
~~~~~~~~~~~~~~~~~~~~
205-
The ``#[PreReRender]`` hook is called before your component is re-rendered
206-
during an HTTP request. It does not run during the initial render but is
207-
helpful when you need to adjust the state before sending it back to
208-
the client for re-rendering.
209-
210-
Hook Priority
211-
~~~~~~~~~~~~~
212-
You can control the order in which hooks are executed by using the ``priority``
213-
argument. If multiple hooks of the same type are registered in a component, those
214-
with a higher priority value will run first. This allows you to manage the order
215-
in which your actions are performed within the same lifecycle stage::
216-
217-
#[PostHydrate(priority: 10)]
218-
public function highPriorityHook(): void
219-
{
220-
// Runs first
221-
}
222-
223-
#[PostHydrate(priority: 1)]
224-
public function lowPriorityHook(): void
225-
{
226-
// Runs last
227-
}
228-
229184
LiveProps: Stateful Component Properties
230185
----------------------------------------
231186

@@ -3425,6 +3380,55 @@ Local variables do remain available:
34253380
{% endblock %}
34263381
{% endcomponent %}
34273382
3383+
Hooks: Handle Component Behavior
3384+
--------------------------------
3385+
3386+
Most of the time, you'll just pass data to your components and let it handle
3387+
the rest. However, if you need to do something more complex during certain
3388+
stages of a component's lifecycle, you can take advantage of lifecycle hooks.
3389+
3390+
``PostHydrate`` Hook
3391+
~~~~~~~~~~~~~~~~~~~~
3392+
3393+
The ``#[PostHydrate]`` hook is called immediately after the component's state
3394+
is loaded from the client. This is useful if you need to process or adjust
3395+
the data once it’s been hydrated.
3396+
3397+
``PreDehydrate`` Hook
3398+
~~~~~~~~~~~~~~~~~~~~~
3399+
3400+
The ``#[PreDehydrate]`` hook is triggered just before your component’s state
3401+
is sent back to the client. You can use this to modify or clean up the data
3402+
before it’s serialized and returned to the client.
3403+
3404+
``PreReRender`` Hook
3405+
~~~~~~~~~~~~~~~~~~~~
3406+
3407+
The ``#[PreReRender]`` hook is called before your component is re-rendered
3408+
during an HTTP request. It does not run during the initial render but is
3409+
helpful when you need to adjust the state before sending it back to the client
3410+
for re-rendering.
3411+
3412+
Hook Priority
3413+
~~~~~~~~~~~~~
3414+
3415+
You can control the order in which hooks are executed by using the ``priority``
3416+
argument. If multiple hooks of the same type are registered in a component,
3417+
those with a higher priority value will run first. This allows you to manage
3418+
the order in which your actions are performed within the same lifecycle stage::
3419+
3420+
#[PostHydrate(priority: 10)]
3421+
public function highPriorityHook(): void
3422+
{
3423+
// Runs first
3424+
}
3425+
3426+
#[PostHydrate(priority: 1)]
3427+
public function lowPriorityHook(): void
3428+
{
3429+
// Runs last
3430+
}
3431+
34283432
Advanced Functionality
34293433
----------------------
34303434

0 commit comments

Comments
 (0)