forked from ethul/purescript-react-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReframe.purs
More file actions
39 lines (31 loc) · 986 Bytes
/
Reframe.purs
File metadata and controls
39 lines (31 loc) · 986 Bytes
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
module Reframe where
import Prelude
import Effect (Effect)
import Effect.Console (log)
import Signal.Channel as C
import Signal as S
import React as React
import Record.Extra as RC
import Prim.RowList as RL
component :: forall props a rl
. RL.RowToList props rl
=> RC.OrdRecord rl props
=> String
-> ({ | props} -> a -> React.ReactElement)
-> S.Signal a
-> React.ReactClass { | props}
component name f s1 = React.component name cmp
where
m = do
log "rendering!"
pure f
shouldUpdate this props state = do
val <- update
log $ show val
not <$> eq EQ <$> update
where update = RC.compareRecord props <$> React.getProps this
cmp this = do
log "mounting!"
pure { state : {}
, shouldComponentUpdate : (shouldUpdate this)
, render : m <*> React.getProps this <*> S.get s1 }