Skip to content

Commit 788199e

Browse files
committed
Fix ComponentSpec state
1 parent d7c1c16 commit 788199e

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/React/Basic.purs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ import Type.Row (class Union)
106106
-- | a React-Basic component from JavaScript, use `toReactComponent`.__
107107
-- |
108108
-- | __*See also:* `Component`, `ComponentSpec`, `make`, `makeStateless`__
109-
type ComponentSpec props state action =
110-
( initialState :: state
109+
type ComponentSpec props state initialState action =
110+
( initialState :: initialState
111111
, update :: Self props state action -> action -> StateUpdate props state action
112112
, render :: Self props state action -> JSX
113113
, shouldUpdate :: Self props state action -> props -> state -> Boolean
@@ -146,10 +146,6 @@ foreign import createComponent
146146
. String
147147
-> Component props
148148

149-
-- | A simplified alias for `ComponentSpec`. This type is usually used to represent
150-
-- | the default component type returned from `createComponent`.
151-
-- type Component props = forall state action. ComponentSpec props state action
152-
153149
-- | Opaque component information for internal use.
154150
-- |
155151
-- | __*Note:* Never define a component with
@@ -289,9 +285,9 @@ foreign import readState :: forall props state action. Self props state action -
289285
-- | __*See also:* `makeStateless`, `createComponent`, `Component`, `ComponentSpec`__
290286
foreign import make
291287
:: forall spec spec_ props state action
292-
. Union spec spec_ (ComponentSpec props state action)
288+
. Union spec spec_ (ComponentSpec props state state action)
293289
=> Component props
294-
-> { render :: Self props state action -> JSX | spec }
290+
-> { initialState :: state, render :: Self props state action -> JSX | spec }
295291
-> props
296292
-> JSX
297293

@@ -318,7 +314,7 @@ makeStateless
318314
-> props
319315
-> JSX
320316
makeStateless component render =
321-
make component { render: \self -> render self.props }
317+
make component { initialState: unit, render: \self -> render self.props }
322318

323319
-- | Represents rendered React VDOM (the result of calling `React.createElement`
324320
-- | in JavaScript).
@@ -430,7 +426,7 @@ data ReactComponentInstance
430426
-- | __*See also:* `ReactComponent`__
431427
foreign import toReactComponent
432428
:: forall spec spec_ jsProps props state action
433-
. Union spec spec_ (ComponentSpec props state action)
429+
. Union spec spec_ (ComponentSpec props state state action)
434430
=> ({ | jsProps } -> props)
435431
-> Component props
436432
-> { render :: Self props state action -> JSX | spec }

0 commit comments

Comments
 (0)