Comments (1)
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
from reflex.
Related Issues (20)
- Wrap Radix Radio Cards (New Component) HOT 2
- Wrap Checkbox Group Radix (New Component) HOT 2
- Wrap Radio Group Radix (New Component) HOT 3
- 404 with recomplilation when working on routes HOT 2
- Can Reflex deal with some state/components running in subprocesses? HOT 5
- Problems submitting additional information via rx.form HOT 1
- [REF-3004] postcss-import causes regression using local stylesheets
- [REF-3006] Inline code rendered in `rx.markdown` has extra trailing space
- [REF-3010] Cannot access rx.color (and others) without first accessing rx.Component
- [REF-3011] Hash in URL does not jump to anchor defined in markdown
- [REF-3013] pyi_generator should not operate on changed files outside of `reflex/components`
- Cannot render states with typing.ForwardRef HOT 3
- [REF-3014] Bug in serializing lists/dict of `rx.Base` HOT 11
- [REF-3016] Upload ID should allow characters
- Make .web folder configurable via env. HOT 2
- Default color mode (dark/light) should be the host system's current mode
- [REF-3056] Cannot set state_manager.lock_expiration easily
- Buttons stop working after a sequence HOT 3
- State hangs after using back button after following a link.
- [REF-2592] Backend Vars in ComponentState are not independent
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reflex.