|
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
5 | | -from typing import TypedDict |
| 5 | +from typing import Any, TypedDict |
6 | 6 |
|
7 | 7 | from reflex.components.component import NoSSRComponent |
8 | 8 | from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec |
@@ -50,12 +50,6 @@ class ReactPlayer(NoSSRComponent): |
50 | 50 | # Mutes the player |
51 | 51 | muted: Var[bool] |
52 | 52 |
|
53 | | - # Set the width of the player: ex:640px |
54 | | - width: Var[str] |
55 | | - |
56 | | - # Set the height of the player: ex:640px |
57 | | - height: Var[str] |
58 | | - |
59 | 53 | # Called when media is loaded and ready to play. If playing is set to true, media will play immediately. |
60 | 54 | on_ready: EventHandler[no_args_event_spec] |
61 | 55 |
|
@@ -103,3 +97,23 @@ class ReactPlayer(NoSSRComponent): |
103 | 97 |
|
104 | 98 | # Called when picture-in-picture mode is disabled. |
105 | 99 | on_disable_pip: EventHandler[no_args_event_spec] |
| 100 | + |
| 101 | + def _render(self, props: dict[str, Any] | None = None): |
| 102 | + """Render the component. Adds width and height set to None because |
| 103 | + react-player will set them to some random value that overrides the |
| 104 | + css width and height. |
| 105 | +
|
| 106 | + Args: |
| 107 | + props: The props to pass to the component. |
| 108 | +
|
| 109 | + Returns: |
| 110 | + The rendered component. |
| 111 | + """ |
| 112 | + return ( |
| 113 | + super() |
| 114 | + ._render(props) |
| 115 | + .add_props( |
| 116 | + width=Var.create(None), |
| 117 | + height=Var.create(None), |
| 118 | + ) |
| 119 | + ) |
0 commit comments