Open iBuitron opened 4 months ago
cond calls the redirect on load the page.
class Upload(rx.ComponentState):
_data: bytes | list[bytes]
show_upload: bool = True
async def upload_single(self, upload_files: list[rx.UploadFile]):
if upload_files:
upload_data = await upload_files[0].read()
self._data = upload_data
self.show_upload = False
async def upload_multiple(self, upload_files: list[rx.UploadFile]):
if upload_files:
upload_data = [await file.read() for file in upload_files]
self._data = upload_data
self.show_upload = False
@classmethod
def get_component(
cls,
id: str,
select_files: Literal["single", "multiple"],
redirect_path: str = "",
) -> rx.Component:
_upload = rx.upload(
rx.vstack(
rx.text("Drag and drop files here or click to select files"),
),
id=id,
on_drop=getattr(cls, f"upload_{select_files}")(
rx.upload_files(upload_id=id)
),
multiple=True if select_files == "multiple" else False,
)
new_upload = rx.box(
rx.cond(
cls.show_upload,
_upload,
rx.fragment(
"Redirecting", on_mount=rx.redirect(redirect_path, external=False)
),
)
)
return new_upload
Describe the bug as you view on rx.cond
when i upload a file, it trigger
on_drop
, sois_upload
change toTrue
Now the
rx.cond
should render therx.fragment
, as my understand thisunMount
the_upload
so it should call hison_unmount
calling therx.redirect
to the path.But, in
prod mode
this doens't call theon_unmount
in_upload
To Reproduce Steps to reproduce the behavior: