Ver Fonte

don't set _state

Khaleel Al-Adhami há 2 meses atrás
pai
commit
be17639a7f

+ 1 - 0
reflex/.templates/web/utils/state.js

@@ -886,6 +886,7 @@ export const useEventLoop = (
     (async () => {
       // Process all outstanding events.
       while (event_queue.length > 0 && !event_processing) {
+        await new Promise((resolve) => setTimeout(resolve, 0));
         await processEvent(socket.current);
       }
     })();

+ 1 - 1
tests/integration/test_background_task.py

@@ -176,7 +176,7 @@ def BackgroundTask():
             rx.button("Reset", on_click=State.reset_counter, id="reset"),
         )
 
-    app = rx.App(_state=rx.State)
+    app = rx.App()
     app.add_page(index)
 
 

+ 1 - 1
tests/integration/test_call_script.py

@@ -187,7 +187,7 @@ def CallScript():
             yield rx.call_script("inline_counter = 0; external_counter = 0")
             self.reset()
 
-    app = rx.App(_state=rx.State)
+    app = rx.App()
     Path("assets/external.js").write_text(external_scripts)
 
     @app.add_page

+ 1 - 1
tests/integration/test_client_storage.py

@@ -127,7 +127,7 @@ def ClientSide():
             rx.box(ClientSideSubSubState.s1s, id="s1s"),
         )
 
-    app = rx.App(_state=rx.State)
+    app = rx.App()
     app.add_page(index)
     app.add_page(index, route="/foo")
 

+ 1 - 1
tests/integration/test_component_state.py

@@ -72,7 +72,7 @@ def ComponentStateApp():
             State=_Counter,
         )
 
-    app = rx.App(_state=rx.State)  # noqa: F841
+    app = rx.App()  # noqa: F841
 
     @rx.page()
     def index():

+ 1 - 1
tests/integration/test_connection_banner.py

@@ -39,7 +39,7 @@ def ConnectionBanner():
             rx.button("Delay", id="delay", on_click=State.delay),
         )
 
-    app = rx.App(_state=rx.State)
+    app = rx.App()
     app.add_page(index)
 
 

+ 1 - 1
tests/integration/test_deploy_url.py

@@ -26,7 +26,7 @@ def DeployUrlSample() -> None:
             rx.button("GOTO SELF", on_click=State.goto_self, id="goto_self")
         )
 
-    app = rx.App(_state=rx.State)
+    app = rx.App()
     app.add_page(index)
 
 

+ 1 - 1
tests/integration/test_dynamic_routes.py

@@ -138,7 +138,7 @@ def DynamicRoute():
     def redirect_page():
         return rx.fragment(rx.text("redirecting..."))
 
-    app = rx.App(_state=rx.State)
+    app = rx.App()
     app.add_page(index, route="/page/[page_id]", on_load=DynamicState.on_load)
     app.add_page(index, route="/static/x", on_load=DynamicState.on_load)
     app.add_page(index)

+ 1 - 1
tests/integration/test_event_actions.py

@@ -154,7 +154,7 @@ def TestEventAction():
             on_click=EventActionState.on_click("outer"),  # pyright: ignore [reportCallIssue]
         )
 
-    app = rx.App(_state=rx.State)
+    app = rx.App()
     app.add_page(index)
 
 

+ 1 - 1
tests/integration/test_event_chain.py

@@ -143,7 +143,7 @@ def EventChain():
             time.sleep(0.5)
             self.interim_value = "final"
 
-    app = rx.App(_state=rx.State)
+    app = rx.App()
 
     token_input = rx.input(
         value=State.router.session.client_token, is_read_only=True, id="token"

+ 1 - 1
tests/integration/test_exception_handlers.py

@@ -39,7 +39,7 @@ def TestApp():
             """
             print(1 / number)
 
-    app = rx.App(_state=rx.State)
+    app = rx.App()
 
     @app.add_page
     def index():

+ 1 - 1
tests/integration/test_extra_overlay_function.py

@@ -25,7 +25,7 @@ def ExtraOverlay():
             ),
         )
 
-    app = rx.App(_state=rx.State)
+    app = rx.App()
     app.add_page(index)
 
 

+ 2 - 2
tests/integration/test_form_submit.py

@@ -30,7 +30,7 @@ def FormSubmit(form_component):
         def form_submit(self, form_data: Dict):
             self.form_data = form_data
 
-    app = rx.App(_state=rx.State)
+    app = rx.App()
 
     @app.add_page
     def index():
@@ -90,7 +90,7 @@ def FormSubmitName(form_component):
         def form_submit(self, form_data: Dict):
             self.form_data = form_data
 
-    app = rx.App(_state=rx.State)
+    app = rx.App()
 
     @app.add_page
     def index():

+ 1 - 1
tests/integration/test_input.py

@@ -16,7 +16,7 @@ def FullyControlledInput():
     class State(rx.State):
         text: str = "initial"
 
-    app = rx.App(_state=rx.State)
+    app = rx.App()
 
     @app.add_page
     def index():

+ 1 - 1
tests/integration/test_login_flow.py

@@ -45,7 +45,7 @@ def LoginSample():
             rx.button("Do it", on_click=State.login, id="doit"),
         )
 
-    app = rx.App(_state=rx.State)
+    app = rx.App()
     app.add_page(index)
     app.add_page(login)
 

+ 1 - 1
tests/integration/test_server_side_event.py

@@ -38,7 +38,7 @@ def ServerSideEvent():
         def set_value_return_c(self):
             return rx.set_value("c", "")
 
-    app = rx.App(_state=rx.State)
+    app = rx.App()
 
     @app.add_page
     def index():

+ 1 - 1
tests/integration/test_upload.py

@@ -166,7 +166,7 @@ def UploadFile():
             rx.text(UploadState.event_order.to_string(), id="event-order"),
         )
 
-    app = rx.App(_state=rx.State)
+    app = rx.App()
     app.add_page(index)
 
 

+ 1 - 1
tests/integration/test_var_operations.py

@@ -44,7 +44,7 @@ def VarOperations():
             [{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}]
         )
 
-    app = rx.App(_state=rx.State)
+    app = rx.App()
 
     @rx.memo
     def memo_comp(list1: list[int], int_var1: int, id: str):

+ 1 - 1
tests/integration/tests_playwright/test_datetime_operations.py

@@ -16,7 +16,7 @@ def DatetimeOperationsApp():
         date2: datetime = datetime(2031, 1, 1)
         date3: datetime = datetime(2021, 1, 1)
 
-    app = rx.App(_state=DtOperationsState)
+    app = rx.App()
 
     @app.add_page
     def index():

+ 1 - 1
tests/integration/tests_playwright/test_table.py

@@ -20,7 +20,7 @@ def Table():
     """App using table component."""
     import reflex as rx
 
-    app = rx.App(_state=rx.State)
+    app = rx.App()
 
     @app.add_page
     def index():