From 60949e24e658152ce8a3d3b420146563c56919f8 Mon Sep 17 00:00:00 2001 From: PeterYusuke <58464065+PeterYusuke@users.noreply.github.com> Date: Thu, 9 Feb 2023 07:09:03 +0900 Subject: [PATCH] Add id for components to support anchors (#469) --- pynecone/components/component.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pynecone/components/component.py b/pynecone/components/component.py index 7ec1230b1..279a9ac2c 100644 --- a/pynecone/components/component.py +++ b/pynecone/components/component.py @@ -44,6 +44,9 @@ class Component(Base, ABC): # A unique key for the component. key: Any = None + # The id for the component. + id: Any = None + @classmethod def __init_subclass__(cls, **kwargs): """Set default properties. @@ -360,7 +363,9 @@ class Component(Base, ABC): """ tag = self._render() return str( - tag.add_props(**self.event_triggers, key=self.key, sx=self.style).set( + tag.add_props( + **self.event_triggers, key=self.key, sx=self.style, id=self.id + ).set( contents=utils.join( [str(tag.contents)] + [child.render() for child in self.children] ).strip(),