https://github.com/astrocoders/reason-epitath
CPS sugar usage for React Render Props composition in ReasonML
https://github.com/astrocoders/reason-epitath
react reasonml render-props
Last synced: about 1 year ago
JSON representation
CPS sugar usage for React Render Props composition in ReasonML
- Host: GitHub
- URL: https://github.com/astrocoders/reason-epitath
- Owner: Astrocoders
- License: mit
- Created: 2018-10-12T05:35:20.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-28T16:48:02.000Z (over 7 years ago)
- Last Synced: 2025-04-30T07:08:53.946Z (about 1 year ago)
- Topics: react, reasonml, render-props
- Language: HTML
- Homepage:
- Size: 157 KB
- Stars: 15
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## bs-epitath demo
Read the article https://medium.com/astrocoders/render-props-composition-for-reasonml-is-here-b9c004ca9fcb
## Running
```
npm install
```
```
npm start
```
```reason
module StateConfig = {
type state = string;
};
/* ReContainers is from https://github.com/Astrocoders/recontainers/ */
module State = ReContainers.WithState.Make(StateConfig);
let component = ReasonReact.statelessComponent("App");
let make = _children => {
...component,
render: _self => {
let%Epitath emailState = children =>
...children ;
{ReasonReact.string("Meet Epitath")}
{ReasonReact.string("Email")}
emailState.send(Set(ReactEvent.Form.target(event)##value))
}
/>
{ReasonReact.string(emailState.state)}
{
/* Combine as many as you want. Use even in the middle of JSX! */
let%Epitath passwordState = children =>
...children ;
<>
{ReasonReact.string("Password")}
passwordState.send(
Set(ReactEvent.Form.target(event)##value),
)
}
/>
{ReasonReact.string(passwordState.state)}
>;
}
;
},
};
```
# Next Steps
Maybe change
```reason
let%Epitath passwordState = children =>
...children ;
```
to
```reason
let%Epitath passwordState = ;
```