File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -79,3 +79,11 @@ exports.renderToElementById = function(id) {
7979 }
8080 }
8181} ;
82+
83+ exports . createElement = function ( factory ) {
84+ return function ( props ) {
85+ return function ( children ) {
86+ return React . createElement . apply ( React , [ factory , props ] . concat ( children ) ) ;
87+ } ;
88+ } ;
89+ } ;
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ module React
2222 , Render ()
2323
2424 , UISpec ()
25+ , UIFactory ()
2526
2627 , Event ()
2728 , MouseEvent ()
@@ -45,6 +46,7 @@ module React
4546 , renderToString
4647 , renderToBody
4748 , renderToElementById
49+ , createElement
4850 ) where
4951
5052import Prelude
@@ -202,6 +204,9 @@ type UISpec props state eff =
202204 ) Unit
203205 }
204206
207+ -- | Factory function for components.
208+ type UIFactory props = props -> UI
209+
205210-- | Create a component specification.
206211spec :: forall props state eff . state -> Render props state eff -> UISpec props state eff
207212spec st render =
@@ -250,8 +255,7 @@ transformState ctx f = do
250255-- | Create a component from a component spec.
251256foreign import mkUI :: forall props state eff .
252257 UISpec props state eff ->
253- props ->
254- UI
258+ UIFactory props
255259
256260-- | Create an event handler.
257261foreign import handle :: forall eff ev props state result .
@@ -266,3 +270,6 @@ foreign import renderToBody :: forall eff. UI -> Eff (dom :: DOM | eff) UI
266270
267271-- | Render a component to the element with the specified ID.
268272foreign import renderToElementById :: forall eff . String -> UI -> Eff (dom :: DOM | eff ) UI
273+
274+ -- | Create an element from a component factory.
275+ foreign import createElement :: forall props . UIFactory props -> props -> Array UI -> UI
You can’t perform that action at this time.
0 commit comments