Skip to content

Commit 34714e4

Browse files
committed
Restrict props to a Record
Fixes #22
1 parent 539cddc commit 34714e4

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

Diff for: examples/component/src/Container.purs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
module Container where
22

3-
import Prelude
4-
53
import React.Basic (ReactComponent, createElement, stateless)
64
import React.Basic.DOM as R
75
import ToggleButton as ToggleButton
86

9-
component :: ReactComponent Unit
7+
component :: ReactComponent {}
108
component = stateless
119
{ displayName: "Container"
1210
, render: \_ ->

Diff for: src/React/Basic.purs

+11-11
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ react
2929
:: forall props state fx
3030
. { displayName :: String
3131
, initialState :: { | state }
32-
, receiveProps :: props -> { | state } -> (SetState state fx) -> Eff (react :: ReactFX | fx) Unit
33-
, render :: props -> { | state } -> (SetState state fx) -> JSX
32+
, receiveProps :: { | props } -> { | state } -> (SetState state fx) -> Eff (react :: ReactFX | fx) Unit
33+
, render :: { | props } -> { | state } -> (SetState state fx) -> JSX
3434
}
35-
-> ReactComponent props
35+
-> ReactComponent { | props }
3636
react { displayName, initialState, receiveProps, render } =
3737
component_
3838
{ displayName
@@ -48,9 +48,9 @@ react { displayName, initialState, receiveProps, render } =
4848
stateless
4949
:: forall props
5050
. { displayName :: String
51-
, render :: props -> JSX
51+
, render :: { | props } -> JSX
5252
}
53-
-> ReactComponent props
53+
-> ReactComponent { | props }
5454
stateless { displayName, render } =
5555
react
5656
{ displayName
@@ -65,8 +65,8 @@ type SetState state fx = ({ | state } -> { | state }) -> Eff (react :: ReactFX |
6565
-- | Create a `JSX` node from a React component, by providing the props.
6666
createElement
6767
:: forall props
68-
. ReactComponent props
69-
-> props
68+
. ReactComponent { | props }
69+
-> { | props }
7070
-> JSX
7171
createElement = runFn2 createElement_
7272

@@ -95,12 +95,12 @@ foreign import component_
9595
:: forall props state fx
9696
. { displayName :: String
9797
, initialState :: { | state }
98-
, receiveProps :: EffFn3 (react :: ReactFX | fx) props { | state } (SetState state fx) Unit
99-
, render :: Fn3 props { | state } (SetState state fx) JSX
98+
, receiveProps :: EffFn3 (react :: ReactFX | fx) { | props } { | state } (SetState state fx) Unit
99+
, render :: Fn3 { | props } { | state } (SetState state fx) JSX
100100
}
101-
-> ReactComponent props
101+
-> ReactComponent { | props }
102102

103-
foreign import createElement_ :: forall props. Fn2 (ReactComponent props) props JSX
103+
foreign import createElement_ :: forall props. Fn2 (ReactComponent { | props }) { | props } JSX
104104

105105
foreign import createElementKeyed_ :: forall props. Fn2 (ReactComponent { | props }) { key :: String | props } JSX
106106

0 commit comments

Comments
 (0)