Skip to content

Add stateless component helper function #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 15, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/React/Basic.purs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module React.Basic
( react
, react_
, createElement
, createElementKeyed
, fragment
Expand Down Expand Up @@ -40,6 +41,24 @@ react { displayName, initialState, receiveProps, render } =
, render: mkFn3 render
}

-- | Create a stateless React component.
-- |
-- | Removes a little bit of the `react` function's boilerplate when creating
-- | components which don't use state.
react_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we name this something like stateless?

:: forall props
. { displayName :: String
, render :: props -> JSX
}
-> ReactComponent props
react_ { displayName, render } =
react
{ displayName
, initialState: unit
, receiveProps: \_ _ _ -> pure unit
, render: \props _ _ -> render props
}

-- | SetState uses an update function to modify the current state.
type SetState state fx = (state -> state) -> Eff (react :: ReactFX | fx) Unit

Expand Down