Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add warning when using css props on recharts #3651

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion reflex/components/recharts/recharts.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
"""A component that wraps a recharts lib."""

from typing import Literal
from typing import Dict, Literal

from reflex.components.component import Component, MemoizationLeaf, NoSSRComponent
from reflex.utils import console


class Recharts(Component):
"""A component that wraps a recharts lib."""

library = "recharts@2.12.7"

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


class RechartsCharts(NoSSRComponent, MemoizationLeaf):
"""A component that wraps a recharts lib."""
Expand Down
1 change: 1 addition & 0 deletions reflex/components/recharts/recharts.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ from reflex.style import Style
from reflex.vars import BaseVar, Var

class Recharts(Component):
def render(self) -> Dict: ...
@overload
@classmethod
def create( # type: ignore
Expand Down
Loading