reflex/reflex/components/props.py
Thomas Brandého 0d39237b3c
upgrade to latest ruff (#3497)
* upgrade to latest ruff

* try to fix dep review

* try to fix dep review (2)

* upgrade black

* upgrade black (2)

* update allowed dependencies

* update allowed dependencies (2)

* update allowed dependencies (3)

* wait between interim and final in yield test

* remove previous commit, increase delay between yield

* forgot to save on the time.sleep(1) removal

* fix integration (maybe?)

* fix pyi?

* what even is going on

* what is realityi?

* test another fix for app harness

* try to wait even longer?

* force uvloop to be optional

* downpin fastapi < 0.111, remove changes to test
2024-06-19 12:32:13 +02:00

32 lines
907 B
Python

"""A class that holds props to be passed or applied to a component."""
from __future__ import annotations
from reflex.base import Base
from reflex.utils import format
from reflex.utils.serializers import serialize
class PropsBase(Base):
"""Base for a class containing props that can be serialized as a JS object."""
def json(self) -> str:
"""Convert the object to a json-like string.
Vars will be unwrapped so they can represent actual JS var names and functions.
Keys will be converted to camelCase.
Returns:
The object as a Javascript Object literal.
"""
return format.unwrap_vars(
self.__config__.json_dumps(
{
format.to_camel_case(key): value
for key, value in self.dict().items()
},
default=serialize,
)
)