Closed
Description
Describe the bug
Hook code snippets that are returned by both _get_all_hooks
and _get_all_hooks_internal
are not de-duplicated, which can lead to rendering problems when const
declarations are re-defined.
To Reproduce
import reflex as rx
class State(rx.State):
"""The app state."""
v: str = "v"
class Foo(rx.Fragment):
bar: rx.Var[str]
def add_hooks(self) -> list[str]:
return [
rx.Var(f"console.log({self.bar})")
]
def render(self):
return {}
def index() -> rx.Component:
return Foo.create(bar=State.v)
app = rx.App()
app.add_page(index)
Expected behavior
All hooks code should always be de-duplicated.
Specifics (please complete the following information):
- Python Version: 3.12
- Reflex Version: 0.6.7.dev1
- OS: macOS
- Browser (Optional): chrome
Additional context
Care should be taken in regard to hook ordering (internal should always come first) and avoiding extra recursive calls (don't call _get_all_hooks_internal
inside _get_all_hooks
to avoid performance implications)
Activity