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