Skip to content

Commit 8563d53

Browse files
Fix all warning messages in reflex-web documentation (#1490)
* Fix all warning messages in reflex-web documentation - Fix type annotations in slider event handlers to use list[int | float] - Add missing set_width_pct method in FlexGrowShrinkState - Remove unsupported on_ready property from rx.script component - Resolves all warnings when running reflex run Files modified: - docs/components/conditional_rendering.md - docs/events/event_actions.md - docs/events/event_arguments.md - docs/library/forms/slider.md - docs/library/graphing/other-charts/pyplot.md - docs/library/layout/flex.md - docs/api-reference/browser_javascript.md Co-Authored-By: Alek <[email protected]> * Optimize snowStorm initialization to avoid button click overhead - Move snowStorm configuration to window load event listener - Eliminates repeated config calls on every Start Duststorm button click - Maintains functionality while improving performance - Addresses feedback about initialization overhead Co-Authored-By: Alek <[email protected]> * Fix num_points conversion to integer for array size compatibility - Convert slider float values to int() for array size operations - Addresses GitHub comment about array size requirements - Maintains type annotation compatibility while ensuring proper integer usage Co-Authored-By: Alek <[email protected]> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Alek <[email protected]>
1 parent 991928b commit 8563d53

File tree

7 files changed

+20
-9
lines changed

7 files changed

+20
-9
lines changed

docs/api-reference/browser_javascript.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,15 @@ via `rx.call_script`.
7777
rx.vstack(
7878
rx.script(
7979
src="https://cdn.jsdelivr.net/gh/scottschiller/snowstorm@snowstorm_20131208/snowstorm-min.js",
80-
on_ready=rx.call_script("snowStorm.autoStart = false; snowStorm.snowColor = '#111'"),
8180
),
81+
rx.script("""
82+
window.addEventListener('load', function() {
83+
if (typeof snowStorm !== 'undefined') {
84+
snowStorm.autoStart = false;
85+
snowStorm.snowColor = '#111';
86+
}
87+
});
88+
"""),
8289
rx.button("Start Duststorm", on_click=rx.call_script("snowStorm.start()")),
8390
rx.button("Toggle Duststorm", on_click=rx.call_script("snowStorm.toggleSnow()")),
8491
)

docs/components/conditional_rendering.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class PropCondState(rx.State):
5555
value: int
5656

5757
@rx.event
58-
def set_end(self, value: list[int]):
58+
def set_end(self, value: list[int | float]):
5959
self.value = value[0]
6060

6161

docs/events/event_actions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class DebounceState(rx.State):
180180
settled_value: int = 50
181181

182182
@rx.event
183-
def update_value(self, value: list[int]):
183+
def update_value(self, value: list[int | float]):
184184
self.settled_value = value[0]
185185

186186

docs/events/event_arguments.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class EventArgStateSlider(rx.State):
1414
value: int = 50
1515

1616
@rx.event
17-
def set_end(self, value: list[int]):
17+
def set_end(self, value: list[int | float]):
1818
self.value = value[0]
1919

2020

docs/library/forms/slider.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SliderState(rx.State):
2424
value: int = 50
2525

2626
@rx.event
27-
def set_end(self, value: list[int]):
27+
def set_end(self, value: list[int | float]):
2828
self.value = value[0]
2929

3030
def slider_intro():
@@ -45,7 +45,7 @@ class RangeSliderState(rx.State):
4545
value_end: int = 75
4646

4747
@rx.event
48-
def set_end(self, value: list[int]):
48+
def set_end(self, value: list[int | float]):
4949
self.value_start = value[0]
5050
self.value_end = value[1]
5151

@@ -77,7 +77,7 @@ class LiveSliderState(rx.State):
7777
value: int = 50
7878

7979
@rx.event
80-
def set_end(self, value: list[int]):
80+
def set_end(self, value: list[int | float]):
8181
self.value = value[0]
8282

8383
def live_slider_intro():

docs/library/graphing/other-charts/pyplot.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ class PyplotState(rx.State):
105105
self.plot_data = tuple(np.random.rand(2, self.num_points) for _ in range(3))
106106
self.scale = [random.uniform(0, 100) for _ in range(self.num_points)]
107107

108-
def set_num_points(self, num_points: list[int]):
109-
self.num_points = num_points[0]
108+
def set_num_points(self, num_points: list[int | float]):
109+
self.num_points = int(num_points[0])
110110
self.randomize()
111111

112112
@rx.var

docs/library/layout/flex.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ affects the computed sizes of the flex items based on the props that are set.
156156
class FlexGrowShrinkState(rx.State):
157157
width_pct: list[int] = [100]
158158

159+
@rx.event
160+
def set_width_pct(self, value: list[int | float]):
161+
self.width_pct = [int(value[0])]
162+
159163

160164
def border_box(*children, **props):
161165
return rx.box(

0 commit comments

Comments
 (0)