Skip to content

Instantly share code, notes, and snippets.

@joefiorini joefiorini/echo.re
Created Apr 4, 2017

Embed
What would you like to do?
My First ReasonML Component
module Echo = {
include ReactRe.Component.Stateful;
let name = "Echo";
type props = unit;
type state = {message: option string};
let getInitialState _ => {message: None};
let handleChange _ event => {
let value = (ReactDOMRe.domElementToObj (ReactEventRe.Form.target event))##value;
Some {message: Some value}
};
let render {state, updater} => {
let message =
switch state.message {
| None => ""
| Some str => str
};
<section>
<input onChange=(updater handleChange) value=message />
(ReactRe.stringToElement message)
</section>
};
};
include ReactRe.CreateComponent Echo;
let createElement = wrapProps ();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.