@@ -22,6 +22,7 @@ module React
22
22
, Render ()
23
23
24
24
, UISpec ()
25
+ , UIFactory ()
25
26
26
27
, Event ()
27
28
, MouseEvent ()
@@ -33,6 +34,7 @@ module React
33
34
34
35
, getProps
35
36
, getRefs
37
+ , getChildren
36
38
37
39
, readState
38
40
, writeState
@@ -45,6 +47,7 @@ module React
45
47
, renderToString
46
48
, renderToBody
47
49
, renderToElementById
50
+ , createElement
48
51
) where
49
52
50
53
import Prelude
@@ -202,6 +205,9 @@ type UISpec props state eff =
202
205
) Unit
203
206
}
204
207
208
+ -- | Factory function for components.
209
+ type UIFactory props = props -> UI
210
+
205
211
-- | Create a component specification.
206
212
spec :: forall props state eff . state -> Render props state eff -> UISpec props state eff
207
213
spec st render =
@@ -227,6 +233,11 @@ foreign import getRefs :: forall write eff.
227
233
UIRef ->
228
234
Eff (refs :: ReactRefs (Read write ) | eff ) Refs
229
235
236
+ -- | Read the component children property.
237
+ foreign import getChildren :: forall props eff .
238
+ UIRef ->
239
+ Eff (props :: ReactProps props | eff ) (Array UI )
240
+
230
241
-- | Write the component state.
231
242
foreign import writeState :: forall state eff .
232
243
UIRef ->
@@ -250,8 +261,7 @@ transformState ctx f = do
250
261
-- | Create a component from a component spec.
251
262
foreign import mkUI :: forall props state eff .
252
263
UISpec props state eff ->
253
- props ->
254
- UI
264
+ UIFactory props
255
265
256
266
-- | Create an event handler.
257
267
foreign import handle :: forall eff ev props state result .
@@ -266,3 +276,6 @@ foreign import renderToBody :: forall eff. UI -> Eff (dom :: DOM | eff) UI
266
276
267
277
-- | Render a component to the element with the specified ID.
268
278
foreign import renderToElementById :: forall eff . String -> UI -> Eff (dom :: DOM | eff ) UI
279
+
280
+ -- | Create an element from a component factory.
281
+ foreign import createElement :: forall props . UIFactory props -> props -> Array UI -> UI
0 commit comments