From efa9fcd6d549e2ce2f50c084e74bc417cf35a271 Mon Sep 17 00:00:00 2001
From: Yummy-Yums <77977520+Yummy-Yums@users.noreply.github.com>
Date: Wed, 15 May 2024 18:52:50 +0000
Subject: [PATCH] FIX - Error: img is a self-closing tag and must neither have
 children nor use dangerouslySetInnerHTML. (#3307)

* fixed errors

* fix CI errors

* CI fix again

* used ruff formatting

* pyi fix

* fix app harness

---------

Co-authored-by: Elijah <elijahahianyo@gmail.com>
---
 reflex/components/component.py          |  2 +-
 reflex/components/el/elements/media.py  | 19 +++++++++++++++++++
 reflex/components/el/elements/media.pyi |  4 +++-
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/reflex/components/component.py b/reflex/components/component.py
index 39a97792e..3608f8fa5 100644
--- a/reflex/components/component.py
+++ b/reflex/components/component.py
@@ -374,7 +374,7 @@ class Component(BaseComponent, ABC):
                 raise ValueError(
                     f"The {(comp_name := type(self).__name__)} does not take in an `{key}` event trigger. If {comp_name}"
                     f" is a third party component make sure to add `{key}` to the component's event triggers. "
-                    f"visit https://reflex.dev/docs/wrapping-react/logic/#event-triggers for more info."
+                    f"visit https://reflex.dev/docs/wrapping-react/guide/#event-triggers for more info."
                 )
             if key in triggers:
                 # Event triggers are bound to event chains.
diff --git a/reflex/components/el/elements/media.py b/reflex/components/el/elements/media.py
index 2865ca66a..88c35e4cc 100644
--- a/reflex/components/el/elements/media.py
+++ b/reflex/components/el/elements/media.py
@@ -1,6 +1,7 @@
 """Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
 from typing import Any, Union
 
+from reflex import Component
 from reflex.vars import Var as Var
 
 from .base import BaseHTML
@@ -116,6 +117,24 @@ class Img(BaseHTML):
     # The name of the map to use with the image
     use_map: Var[Union[str, int, bool]]
 
+    @classmethod
+    def create(cls, *children, **props) -> Component:
+        """Override create method to apply source attribute to value if user fails to pass in attribute.
+
+        Args:
+            *children: The children of the component.
+            **props: The props of the component.
+
+        Returns:
+            The component.
+
+        """
+        return (
+            super().create(src=children[0], **props)
+            if children
+            else super().create(*children, **props)
+        )
+
 
 class Map(BaseHTML):
     """Display the map element."""
diff --git a/reflex/components/el/elements/media.pyi b/reflex/components/el/elements/media.pyi
index d1aa40978..53e2a341f 100644
--- a/reflex/components/el/elements/media.pyi
+++ b/reflex/components/el/elements/media.pyi
@@ -8,6 +8,7 @@ from reflex.vars import Var, BaseVar, ComputedVar
 from reflex.event import EventChain, EventHandler, EventSpec
 from reflex.style import Style
 from typing import Any, Union
+from reflex import Component
 from reflex.vars import Var as Var
 from .base import BaseHTML
 
@@ -470,7 +471,7 @@ class Img(BaseHTML):
         ] = None,
         **props
     ) -> "Img":
-        """Create the component.
+        """Override create method to apply source attribute to value if user fails to pass in attribute.
 
         Args:
             *children: The children of the component.
@@ -512,6 +513,7 @@ class Img(BaseHTML):
 
         Returns:
             The component.
+
         """
         ...