Refactoring related to ReactPy v2.0.0#294
Refactoring related to ReactPy v2.0.0#294shawncrawley wants to merge 8 commits intoreactive-python:mainfrom
Conversation
|
So I actually realized that most of the pyscript code here in 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 listI 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. |
…ot figure out why re-exported `reactpy/client` hook stack was broken on function based components)
|
A lot of the PyScript logic in this repo has Django specific optimizations, so unfortunately nearly all of that code will remain duplicated for now. Will make a follow-up issue to de-duplicate (make the variant in core to be more 'pluggable'). |
|
Gotcha. I really tried to compare the code in reactpy-django vs reactpy core to ensure I wasn't missing any django-specific stuff and only replace it if they were identical in their outcome, and it really seemed like a good chunk of it met that criteria. I of course trust you, I'm just surprised at what I must have missed. I'll stand down and let you round out the rest of this PR, since you've been at work on it. Thanks for your help! |
|
Feel free to switch to any pyscript code that doesn't break any Django specific logic. I think a decent amount of it relies on Django cache, template tags, and url routing though. |
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:
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:
By submitting this pull request I agree that all contributions comply with this project's open source license(s).