move add ref to component level render (#1019)
This commit is contained in:
parent
b056b79479
commit
928501662e
@ -320,6 +320,11 @@ class Component(Base, ABC):
|
||||
if hasattr(self, "as_"):
|
||||
props["as"] = self.as_ # type: ignore
|
||||
|
||||
# Add ref to element if `id` is not None.
|
||||
ref = self.get_ref()
|
||||
if ref is not None:
|
||||
props["ref"] = Var.create(ref, is_local=False)
|
||||
|
||||
return tag.add_props(**props)
|
||||
|
||||
@classmethod
|
||||
|
@ -70,13 +70,6 @@ class Input(ChakraComponent):
|
||||
"on_key_up": EVENT_ARG.key,
|
||||
}
|
||||
|
||||
def _render(self):
|
||||
out = super()._render()
|
||||
ref = self.get_ref()
|
||||
if ref is not None:
|
||||
out.add_props(ref=Var.create(ref, is_local=False))
|
||||
return out
|
||||
|
||||
|
||||
class InputGroup(ChakraComponent):
|
||||
"""The InputGroup component is a component that is used to group a set of inputs."""
|
||||
|
Loading…
Reference in New Issue
Block a user