Skip to content

Commit ab287a2

Browse files
committed
Adding getChildren function
Allows for access to the implicit `children` prop on components.
1 parent caec2a7 commit ab287a2

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

docs/React.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,14 @@ getRefs :: forall write eff. UIRef -> Eff (refs :: ReactRefs (Read write) | eff)
192192

193193
Read the component refs.
194194

195+
#### `getChildren`
196+
197+
``` purescript
198+
getChildren :: forall props eff. UIRef -> Eff (props :: ReactProps props | eff) (Array UI)
199+
```
200+
201+
Read the component children property.
202+
195203
#### `writeState`
196204

197205
``` purescript

src/React.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ exports.getRefs = function(ctx) {
1515
};
1616
};
1717

18+
exports.getChildren = function(ctx) {
19+
return function() {
20+
return ctx.props.children;
21+
};
22+
};
23+
1824
exports.writeState = function(ctx) {
1925
return function(state) {
2026
return function() {

src/React.purs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ module React
3434

3535
, getProps
3636
, getRefs
37+
, getChildren
3738

3839
, readState
3940
, writeState
@@ -232,6 +233,11 @@ foreign import getRefs :: forall write eff.
232233
UIRef ->
233234
Eff (refs :: ReactRefs (Read write) | eff) Refs
234235

236+
-- | Read the component children property.
237+
foreign import getChildren :: forall props eff.
238+
UIRef ->
239+
Eff (props :: ReactProps props | eff) (Array UI)
240+
235241
-- | Write the component state.
236242
foreign import writeState :: forall state eff.
237243
UIRef ->

0 commit comments

Comments
 (0)