FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
razzle/examples/with-reason-react/src/CommentsPage.re at master · javascriptit/razzle · GitHub
javascriptit
razzle
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
razzle
/
examples
/
with-reason-react
/
src
/
CommentsPage.re
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
59 lines (53 loc) · 1.56 KB
Breadcrumbs
razzle
/
examples
/
with-reason-react
/
src
/
CommentsPage.re
Copy path
File metadata and controls
executable file
·
59 lines (53 loc) · 1.56 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
open
Utils
;
requireCSS(
"../../../src/CommentsPage.css"
)
;
type
state
=
{story_with_comments
:
option
(
StoryData
.
story_with_comments
)}
;
type
action
=
|
Loaded
(
StoryData
.
story_with_comments
)
;
[
@
react
.
component
]
let
make
=
(~id)
=>
{
let
(
state
,
dispatch
)
=
React
.
useReducer((_state
,
action)
=>
switch
(action) {
|
Loaded
(
data
)
=>
{story_with_comments
:
Some
(data)}
}
,
{story_with_comments
:
None
})
;
let
renderTitle
=
(story
:
StoryData
.
story_with_comments
)
=>
{
let
title
=
<
h2
className
=
"CommentsPage_title"
>
{
React
.
string(story
.
title)}
</
h2
>
;
<
div
>
{
switch
(story
.
url) {
|
Some
(
url
)
=>
<
a
href
=
url className
=
"CommentsPage_titleLink"
> title </
a
>
|
None
=>
title
}}
</
div
>
;
}
;
let
renderByline
=
(story
:
StoryData
.
story_with_comments
)
=>
<
div
>
<
span
> {
React
.
string(string_of_int(story
.
score))} </
span
>
{
React
.
string(
" points"
)}
<
span
>
<
span
>
{
let
time
=
story
.
time
let
by
=
story
.
by
React
.
string(
{
j
|
submitted $time by $by
|
j
}
)}
</
span
>
</
span
>
</
div
>
;
React
.
useEffect0(
()
=>
{
StoryData
.
fetchStoryWithComments(id
,
data
=>
dispatch(
Loaded
(data)))
|>
ignore
;
None
;
})
;
<
div
className
=
"CommentsPage_container"
>
{
switch
(state
.
story_with_comments) {
|
Some
(
story
)
=>
<
div
>
{renderTitle(story)}
{renderByline(story)}
<
CommentList
story />
</
div
>
|
None
=>
React
.
string(
"loading"
)
}}
</
div
>
;
}
;
Back
|
FazBrowse Home
|
New Git URL