Skip to content

Commit

Permalink
Disallow children prop except in 'unsafe' variant
Browse files Browse the repository at this point in the history
  • Loading branch information
megamaddu committed Nov 6, 2019
1 parent 34f3fcc commit becf098
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/React/Basic/Hooks.purs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module React.Basic.Hooks
( component
, unsafeComponent
, memo
, UseState
, useState
Expand Down Expand Up @@ -54,12 +55,23 @@ import Unsafe.Reference (unsafeRefEq)
-- | lifecycles or render functions.
component ::
forall hooks props.
Lacks "children" props =>
Lacks "key" props =>
Lacks "ref" props =>
String ->
({ | props } -> Render Unit hooks JSX) ->
Effect (ReactComponent { | props })
component name renderFn =
component = unsafeComponent

-- | Identical to `component`, but allows the unsafe use of the `children` prop.
unsafeComponent ::
forall hooks props.
Lacks "key" props =>
Lacks "ref" props =>
String ->
({ | props } -> Render Unit hooks JSX) ->
Effect (ReactComponent { | props })
unsafeComponent name renderFn =
let
c =
unsafeReactFunctionComponent
Expand Down

0 comments on commit becf098

Please sign in to comment.