Main: fix type errors related thermite and react components

parent 8c7056d3
......@@ -9,15 +9,18 @@ import Gargantext.Pages.Layout.Specs (layoutSpec)
import Gargantext.Pages.Layout.States (initAppState)
import Gargantext.Router (routeHandler, routing)
import Partial.Unsafe (unsafePartial)
import React (ReactThis)
import React as R
import ReactDOM as RDOM
import Record.Unsafe (unsafeSet)
import Routing.Hash (getHash, matches, setHash)
import Thermite (createClass)
import Thermite as T
import Web.DOM.ParentNode (QuerySelector(..), querySelector)
import Web.HTML (window)
import Web.HTML.Window (document)
import Web.HTML.HTMLDocument (toParentNode)
setComponentWillMount :: forall s. Effect Unit -> Record s -> Record (componentWillMount :: Effect Unit | s)
setComponentWillMount = unsafeSet "componentWillMount"
main :: Effect Unit
main = do
......@@ -25,13 +28,14 @@ main = do
{ spec, dispatcher } -> void $ do
let setRouting this = void $ do
matches routing (routeHandler (dispatchAction (dispatcher this)))
spec' = spec { componentWillMount = setRouting }
spec' this = setComponentWillMount (setRouting this) <$> (spec this)
document <- window >>= document
container <- unsafePartial (fromJust <$> querySelector (QuerySelector "#app") (document))
container <- unsafePartial (fromJust <$> querySelector (QuerySelector "#app") (toParentNode document))
h <- getHash
case h of
"" -> setHash "/"
_ -> do
setHash "/"
setHash h
RDOM.render (R.unsafeCreateElement (createClass spec') {}) container
let e = R.unsafeCreateElement (R.component "GargantextMain" spec) {} []
RDOM.render e container
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment