@@ -11,12 +11,14 @@ const htmlHeader = `-- | ----------------------------------------
1111module React.Basic.DOM.Generated where
1212
1313import Data.Nullable (Nullable)
14+ import Effect.Unsafe (unsafePerformEffect)
1415import Foreign.Object (Object)
1516import Prim.Row (class Union)
16- import Web.DOM (Node)
1717import React.Basic (JSX, ReactComponent, Ref, element)
1818import React.Basic.DOM.Internal (CSS, unsafeCreateDOMComponent)
1919import React.Basic.Events (EventHandler)
20+ import Unsafe.Coerce (unsafeCoerce)
21+ import Web.DOM (Node)
2022
2123` ;
2224
@@ -39,11 +41,13 @@ const svgHeader = `-- | ----------------------------------------
3941module React.Basic.DOM.SVG where
4042
4143import Data.Nullable (Nullable)
44+ import Effect.Unsafe (unsafePerformEffect)
4245import Foreign.Object (Object)
4346import Prim.Row (class Union)
44- import Web.DOM (Node)
4547import React.Basic (JSX, ReactComponent, Ref, element)
4648import React.Basic.DOM.Internal (SharedSVGProps, unsafeCreateDOMComponent)
49+ import Unsafe.Coerce (unsafeCoerce)
50+ import Web.DOM (Node)
4751
4852` ;
4953
@@ -105,20 +109,24 @@ const generatePropTypes = (elements, props, sharedPropType) =>
105109 . Union attrs attrs_ ${ propType }
106110 => Record attrs
107111 -> JSX
108- ${ symbol } = element ${ symbol } '
109-
110- ${ symbol } '
111- :: forall attrs attrs_
112- . Union attrs attrs_ ${ propType }
113- => ReactComponent (Record attrs)
114- ${ symbol } ' = unsafeCreateDOMComponent "${ e } "${
112+ ${ symbol } = element ${ symbol } '${
115113 noChildren
116114 ? ""
117115 : `
118116
119117 ${ e } _ :: Array JSX -> JSX
120118 ${ e } _ children = ${ symbol } { children }`
121119 }
120+
121+ ${ symbol } '
122+ :: forall attrs attrs_
123+ . Union attrs attrs_ ${ propType }
124+ => ReactComponent (Record attrs)
125+ ${ symbol } ' = unsafeCoerce _${ e } '
126+
127+ _${ e } '
128+ :: ReactComponent (Record ${ propType } )
129+ _${ e } ' = unsafePerformEffect (unsafeCreateDOMComponent "${ e } ")
122130` ;
123131 } ) . map ( x => x . replace ( / ^ \n \ { 4 } / , "" ) . replace ( / \n \ { 4 } / g, "\n" ) )
124132 . join ( "\n" ) ;
0 commit comments