Skip to content

Commit becf098

Browse files
committed
Disallow children prop except in 'unsafe' variant
1 parent 34f3fcc commit becf098

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Diff for: src/React/Basic/Hooks.purs

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module React.Basic.Hooks
22
( component
3+
, unsafeComponent
34
, memo
45
, UseState
56
, useState
@@ -54,12 +55,23 @@ import Unsafe.Reference (unsafeRefEq)
5455
-- | lifecycles or render functions.
5556
component ::
5657
forall hooks props.
58+
Lacks "children" props =>
5759
Lacks "key" props =>
5860
Lacks "ref" props =>
5961
String ->
6062
({ | props } -> Render Unit hooks JSX) ->
6163
Effect (ReactComponent { | props })
62-
component name renderFn =
64+
component = unsafeComponent
65+
66+
-- | Identical to `component`, but allows the unsafe use of the `children` prop.
67+
unsafeComponent ::
68+
forall hooks props.
69+
Lacks "key" props =>
70+
Lacks "ref" props =>
71+
String ->
72+
({ | props } -> Render Unit hooks JSX) ->
73+
Effect (ReactComponent { | props })
74+
unsafeComponent name renderFn =
6375
let
6476
c =
6577
unsafeReactFunctionComponent

0 commit comments

Comments
 (0)