Created
March 13, 2020 01:28
-
-
Save ksaldana1/6e0506a16172e45f28e67d6431ca23f1 to your computer and use it in GitHub Desktop.
reason_example_1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Query = [%relay.query | |
{| | |
query AppQuery { | |
messages { | |
id | |
text | |
author { | |
__typename | |
...on User { | |
id | |
name | |
role | |
} | |
...on Guest { | |
placeholder | |
} | |
} | |
} | |
} | |
|} | |
]; | |
module Styles = { | |
open Css; | |
let app = | |
style([ | |
display(`flex), | |
justifyContent(`center), | |
alignItems(`center), | |
flexDirection(`column), | |
minHeight(`vh(100.0)), | |
]); | |
}; | |
[@react.component] | |
let make = () => { | |
let query = Query.use(~variables=(), ()); | |
<div className=Styles.app> | |
{Belt.Array.map(query.messages, message => { | |
switch (message.author) { | |
| `User(user) => | |
<div> {React.string(user.name ++ ": " ++ message.text)} </div> | |
| `Guest(guest) => | |
<div> | |
{React.string(guest.placeholder ++ ": " ++ message.text)} | |
</div> | |
| `UnmappedUnionMember => React.null | |
} | |
}) | |
->React.array} | |
</div>; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment