forked from ethul/purescript-webpack-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.purs
More file actions
31 lines (19 loc) · 711 Bytes
/
Example.purs
File metadata and controls
31 lines (19 loc) · 711 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
module Example (example) where
import Prelude (Unit, ($), (>>=), bind, unit, void)
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (log)
import Control.Monad.Eff.Unsafe (unsafePerformEff)
import DOM.Node.Types (Element)
import React (createElement)
import ReactDOM (render, renderToString)
import Example.App (app)
example :: Unit
example = unsafePerformEff $ do
let appEl = createElement app unit []
if isServerSide
then void (log (renderToString appEl))
else void (getElementById "app" >>= render appEl)
hot
foreign import isServerSide :: Boolean
foreign import getElementById :: forall eff. String -> Eff eff Element
foreign import hot :: forall eff. Eff eff Unit