From a320d062fb739235642c95fc4907f7d5f9531e44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Brand=C3=A9ho?= Date: Mon, 2 Dec 2024 09:20:33 -0800 Subject: [PATCH] enable css props via wrapperStyle for recharts components (#4447) --- reflex/components/recharts/recharts.py | 16 ++-------------- reflex/components/recharts/recharts.pyi | 1 - 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/reflex/components/recharts/recharts.py b/reflex/components/recharts/recharts.py index a0d683f72..b5a4ed113 100644 --- a/reflex/components/recharts/recharts.py +++ b/reflex/components/recharts/recharts.py @@ -3,7 +3,6 @@ from typing import Dict, Literal from reflex.components.component import Component, MemoizationLeaf, NoSSRComponent -from reflex.utils import console class Recharts(Component): @@ -11,19 +10,8 @@ class Recharts(Component): library = "recharts@2.13.0" - def render(self) -> Dict: - """Render the tag. - - Returns: - The rendered tag. - """ - tag = super().render() - if any(p.startswith("css") for p in tag["props"]): - console.warn( - f"CSS props do not work for {self.__class__.__name__}. Consult docs to style it with its own prop." - ) - tag["props"] = [p for p in tag["props"] if not p.startswith("css")] - return tag + def _get_style(self) -> Dict: + return {"wrapperStyle": self.style} class RechartsCharts(NoSSRComponent, MemoizationLeaf): diff --git a/reflex/components/recharts/recharts.pyi b/reflex/components/recharts/recharts.pyi index 10e1b96c1..65e65bce1 100644 --- a/reflex/components/recharts/recharts.pyi +++ b/reflex/components/recharts/recharts.pyi @@ -11,7 +11,6 @@ from reflex.style import Style from reflex.vars.base import Var class Recharts(Component): - def render(self) -> Dict: ... @overload @classmethod def create( # type: ignore