MCPcopy Create free account
hub / github.com/dot-agent/nextpy / create

Method create

nextpy/frontend/components/component.py:545–578  ·  view source on GitHub ↗

Create the component. Args: *children: The children of the component. **props: The props of the component. Returns: The component. Raises: TypeError: If an invalid child is passed.

(cls, *children, **props)

Source from the content-addressed store, hash-verified

543
544 @classmethod
545 def create(cls, *children, **props) -> Component:
546 """Create the component.
547
548 Args:
549 *children: The children of the component.
550 **props: The props of the component.
551
552 Returns:
553 The component.
554
555 Raises:
556 TypeError: If an invalid child is passed.
557 """
558 # Import here to avoid circular imports.
559 from nextpy.frontend.components.base.bare import Bare
560
561 # Validate all the children.
562 for child in children:
563 # Make sure the child is a valid type.
564 if not types._isinstance(child, ComponentChild):
565 raise TypeError(
566 "Children of Nextpy components must be other components, "
567 "state vars, or primitive Python types. "
568 f"Got child {child} of type {type(child)}.",
569 )
570
571 children = [
572 child
573 if isinstance(child, Component)
574 else Bare.create(contents=Var.create(child, _var_is_string=True))
575 for child in children
576 ]
577
578 return cls(children=children, **props)
579
580 def _add_style(self, style: dict):
581 """Add additional style to the component.

Callers 7

__init_subclass__Method · 0.45
__init__Method · 0.45
_renderMethod · 0.45
_get_styleMethod · 0.45
__init__Method · 0.45
compile_fromMethod · 0.45
createMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected