Skip to content

Commit 8e0879c

Browse files
committed
changes
1 parent e28dbb5 commit 8e0879c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

pcweb/pages/docs/custom_components.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ class CustomComponentGalleryState(rx.State):
3434
# Added available limits for the number of items per page
3535
limits: list[str] = ["10", "20", "50", "100"]
3636

37-
@rx.event(background=True)
37+
@rx.event(background=True, temporal=True)
3838
async def fetch_components_list(self):
3939
try:
40-
response = httpx.get(
41-
f"{os.getenv('RCC_ENDPOINT')}/custom-components/gallery"
42-
)
43-
response.raise_for_status()
44-
component_list = response.json()
40+
async with httpx.AsyncClient() as client:
41+
response = await client.get(
42+
f"{os.getenv('RCC_ENDPOINT')}/custom-components/gallery"
43+
)
44+
response.raise_for_status()
45+
component_list = response.json()
4546
except (httpx.HTTPError, json.JSONDecodeError) as ex:
4647
print(f"Internal error: failed to fetch components list due to: {ex}")
4748
return
@@ -61,7 +62,7 @@ async def fetch_components_list(self):
6162
self.total_pages = (
6263
self.number_of_rows + self.current_limit - 1
6364
) // self.current_limit
64-
self.paginate()
65+
yield CustomComponentGalleryState.paginate()
6566

6667
@rx.event
6768
def paginate(self) -> None:

0 commit comments

Comments
 (0)