Skip to content

Refactoring related to ReactPy v2.0.0#294

Open
shawncrawley wants to merge 2 commits intoreactive-python:mainfrom
shawncrawley:refactor-for-reactpy2.0
Open

Refactoring related to ReactPy v2.0.0#294
shawncrawley wants to merge 2 commits intoreactive-python:mainfrom
shawncrawley:refactor-for-reactpy2.0

Conversation

@shawncrawley
Copy link

@shawncrawley shawncrawley commented Feb 12, 2026

Description

My attempt at refactoring to align with ReactPy v2.0.0. This depends upon the refactors that were also made to reactpy-router to align with ReactPy v2.0.0 (see PR for that here).

There are a few remaining fixes/updates that I haven't been able to figure out yet. These are the related tests that fail when I run them locally:

  • tests\test_app\tests/test_components.py:230 ComponentTests.test_component_use_user_data
  • tests\test_app\tests/test_components.py:286 ComponentTests.test_component_use_user_data_with_default
  • tests\test_app\tests/test_components.py:685 ComponentTests.test_form_basic
  • tests\test_app\tests/test_components.py:779 ComponentTests.test_form_bootstrap
  • tests\test_app\tests/test_components.py:817 ComponentTests.test_form_orm_model
  • tests\test_app\tests/test_components.py:575 ComponentTests.test_pyscript_1_multifile

The first two are related to open discussion here. As for the rest, I still have no idea what the problem is after digging for hours.

Checklist

Please update this checklist as you complete each item:

  • Tests have been developed for bug fixes or new functionality.
  • The changelog has been updated, if necessary.
  • Documentation has been updated, if necessary.
  • GitHub Issues closed by this PR have been linked.

By submitting this pull request I agree that all contributions comply with this project's open source license(s).

@shawncrawley shawncrawley requested a review from a team as a code owner February 12, 2026 18:32
@shawncrawley
Copy link
Author

shawncrawley commented Feb 15, 2026

So I actually realized that most of the pyscript code here in reactpy-django is now duplicated in reactpy core. I went through and essentially removed essentially all of the duplicate code and just reference it in reactpy. With this change, I still get the same test failing that I couldn't ever figure out why before, but now I'm actually getting a py-script error rather than silent/masked failures. Here is that error:

Unhandled exception in event loop
Traceback (most recent call last):
  File "/lib/python3.13/site-packages/reactpy/executors/pyscript/layout_handler.py", line 157, in run
    update = await root_layout.render()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.13/site-packages/reactpy/core/layout.py", line 122, in render
    return await self._parallel_render()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.13/site-packages/reactpy/core/layout.py", line 158, in _parallel_render
    return update_task.result()
           ~~~~~~~~~~~~~~~~~~^^
  File "/lib/python3.13/site-packages/reactpy/core/layout.py", line 174, in _create_layout_update
    new_state = await self._render_component(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<6 lines>...
    )
    ^
  File "/lib/python3.13/site-packages/reactpy/core/layout.py", line 279, in _render_component
    await life_cycle_hook.affect_component_did_render()
  File "/lib/python3.13/site-packages/reactpy/core/_life_cycle_hook.py", line 232, in affect_component_did_render
    self.unset_current()
    ~~~~~~~~~~~~~~~~~~^^
  File "/lib/python3.13/site-packages/reactpy/core/_life_cycle_hook.py", line 271, in unset_current
    if HOOK_STACK.get().pop() is not self:
       ~~~~~~~~~~~~~~~~~~~~^^
IndexError: pop from empty list

I haven't pushed these code updates since I haven't solved this bug and wanted some feedback on it. Also, I wanted to make sure that purging most of the pyscript code from reactpy-django and instead referencing it in reactpy core is desired. Let me know your thoughts on this. I'm happy to push my code updates if desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants