Skip to content

Commit 84adeea

Browse files
committed
Add stateless component helper function
1 parent 9927842 commit 84adeea

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Diff for: src/React/Basic.purs

+18
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,24 @@ react { displayName, initialState, receiveProps, render } =
4040
, render: mkFn3 render
4141
}
4242

43+
-- | Create a stateless React component.
44+
-- |
45+
-- | Removes a little bit of the `react` function's boilerplate when creating
46+
-- | components which don't use state.
47+
react_
48+
:: forall props
49+
. { displayName :: String
50+
, render :: props -> JSX
51+
}
52+
-> ReactComponent props
53+
react_ { displayName, render } =
54+
react
55+
{ displayName
56+
, initialState: unit
57+
, receiveProps: \_ _ _ -> pure unit
58+
, render: \props _ _ -> render props
59+
}
60+
4361
-- | SetState uses an update function to modify the current state.
4462
type SetState state fx = (state -> state) -> Eff (react :: ReactFX | fx) Unit
4563

0 commit comments

Comments
 (0)