ITADN

[regression] Using state in AppWrap components: TypeError: null is not an object

#6650Openmasenf 创建于 2026-06-10
M
masenfcommented
**Describe the bug** Because the StateProvider and EventLoopProvider are now swept up as normal app_wrap components, any attempt to access state in another AppWrap component fails because the hooks are moved to the top of AppWrap, but at that point, they have not been fulfilled so the context values are null. **To Reproduce** ```python import reflex as rx class FooState(rx.State): flag: bool = False def index() -> rx.Component: return rx.text("hello") app = rx.App( theme=rx.theme( rx.cond(FooState.flag, rx.text("state var in theme"), rx.fragment()), ), ) app.add_page(index, route="/") ``` **Expected behavior** State vars should be usable in any AppWrap component that is defined _below_ StateProvider. **Specifics (please complete the following information):** - Python Version: 3.10+ - Reflex Version: 0.9.5 - OS: any
1 条评论