@@ -38,7 +38,7 @@ module React
3838
3939 , EventHandlerContext ()
4040
41- , spec
41+ , spec , spec'
4242
4343 , getProps
4444 , getRefs
@@ -244,19 +244,23 @@ type ReactSpec props state eff =
244244 , componentWillUnmount :: ComponentWillUnmount props state eff
245245 }
246246
247- -- | Create a component specification.
247+ -- | Create a component specification with a provided state .
248248spec :: forall props state eff . state -> Render props state eff -> ReactSpec props state eff
249- spec st renderFn =
250- { render: renderFn
251- , displayName: " "
252- , getInitialState: \_ -> pure st
253- , componentWillMount: \_ -> return unit
254- , componentDidMount: \_ -> return unit
249+ spec state = spec' (\_ -> pure state)
250+
251+ -- | Create a component specification with a get initial state function.
252+ spec' :: forall props state eff . GetInitialState props state eff -> Render props state eff -> ReactSpec props state eff
253+ spec' getInitialState renderFn =
254+ { render: renderFn
255+ , displayName: " "
256+ , getInitialState: getInitialState
257+ , componentWillMount: \_ -> return unit
258+ , componentDidMount: \_ -> return unit
255259 , componentWillReceiveProps: \_ _ -> return unit
256- , shouldComponentUpdate: \_ _ _ -> return true
257- , componentWillUpdate: \_ _ _ -> return unit
258- , componentDidUpdate: \_ _ _ -> return unit
259- , componentWillUnmount: \_ -> return unit
260+ , shouldComponentUpdate: \_ _ _ -> return true
261+ , componentWillUpdate: \_ _ _ -> return unit
262+ , componentDidUpdate: \_ _ _ -> return unit
263+ , componentWillUnmount: \_ -> return unit
260264 }
261265
262266-- | React class for components.
0 commit comments