MCPcopy
hub / github.com/reflex-dev/reflex / field

Function field

packages/reflex-base/src/reflex_base/components/component.py:129–157  ·  view source on GitHub ↗

Create a field for a component. Args: default: The default value for the field. default_factory: The default factory for the field. is_javascript_property: Whether the field is a javascript property. doc: Documentation string for the field. Returns:

(
    default: FIELD_TYPE | _MISSING_TYPE = MISSING,
    default_factory: Callable[[], FIELD_TYPE] | None = None,
    is_javascript_property: bool | None = None,
    doc: str | None = None,
)

Source from the content-addressed store, hash-verified

127
128
129def field(
130 default: FIELD_TYPE | _MISSING_TYPE = MISSING,
131 default_factory: Callable[[], FIELD_TYPE] | None = None,
132 is_javascript_property: bool | None = None,
133 doc: str | None = None,
134) -> FIELD_TYPE:
135 """Create a field for a component.
136
137 Args:
138 default: The default value for the field.
139 default_factory: The default factory for the field.
140 is_javascript_property: Whether the field is a javascript property.
141 doc: Documentation string for the field.
142
143 Returns:
144 The field for the component.
145
146 Raises:
147 ValueError: If both default and default_factory are specified.
148 """
149 if default is not MISSING and default_factory is not None:
150 msg = "cannot specify both default and default_factory"
151 raise ValueError(msg)
152 return ComponentField( # pyright: ignore [reportReturnType]
153 default=default,
154 default_factory=default_factory,
155 is_javascript=is_javascript_property,
156 doc=doc,
157 )
158
159
160def _field_values_equal(a: Any, b: Any) -> bool:

Callers 15

IconClass · 0.90
DataEditorClass · 0.90
DataTableClass · 0.90
CondClass · 0.90
WindowEventListenerClass · 0.90
HtmlClass · 0.90
ClipboardClass · 0.90
MatchClass · 0.90
DebounceInputClass · 0.90
ForeachClass · 0.90
GhostUploadClass · 0.90
UploadClass · 0.90

Calls 1

ComponentFieldClass · 0.85

Tested by

no test coverage detected