File tree 1 file changed +8
-4
lines changed
1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -561,15 +561,19 @@ class LifeCycleHook:
561
561
562
562
.. testcode::
563
563
564
- from idom.core.hooks import LifeCycleHook, DID_RENDER_EFFECT
564
+ from idom.core.hooks import (
565
+ current_hook,
566
+ LifeCycleHook,
567
+ COMPONENT_DID_RENDER_EFFECT,
568
+ )
565
569
566
570
567
571
# this function will come from a layout implementation
568
572
schedule_render = lambda: ...
569
573
570
574
# --- start life cycle ---
571
575
572
- hook = hooks.LifeCycle (schedule_render)
576
+ hook = LifeCycleHook (schedule_render)
573
577
574
578
# --- start render cycle ---
575
579
@@ -582,11 +586,11 @@ class LifeCycleHook:
582
586
...
583
587
584
588
# the component may access the current hook
585
- assert hooks. current_hook() is hook
589
+ assert current_hook() is hook
586
590
587
591
# and save state or add effects
588
592
current_hook().use_state(lambda: ...)
589
- current_hook().use_effect(DID_RENDER_EFFECT , lambda: ...)
593
+ current_hook().use_effect(COMPONENT_DID_RENDER_EFFECT , lambda: ...)
590
594
finally:
591
595
hook.unset_current()
592
596
You can’t perform that action at this time.
0 commit comments