diff --git a/pynecone/components/component.py b/pynecone/components/component.py index 9f2607bb8..1ee94c876 100644 --- a/pynecone/components/component.py +++ b/pynecone/components/component.py @@ -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 diff --git a/pynecone/components/forms/input.py b/pynecone/components/forms/input.py index 3d479a678..3fd1efb10 100644 --- a/pynecone/components/forms/input.py +++ b/pynecone/components/forms/input.py @@ -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."""