Main: fix type errors related thermite and react components

parent 8c7056d3
...@@ -9,15 +9,18 @@ import Gargantext.Pages.Layout.Specs (layoutSpec) ...@@ -9,15 +9,18 @@ import Gargantext.Pages.Layout.Specs (layoutSpec)
import Gargantext.Pages.Layout.States (initAppState) import Gargantext.Pages.Layout.States (initAppState)
import Gargantext.Router (routeHandler, routing) import Gargantext.Router (routeHandler, routing)
import Partial.Unsafe (unsafePartial) import Partial.Unsafe (unsafePartial)
import React (ReactThis)
import React as R import React as R
import ReactDOM as RDOM import ReactDOM as RDOM
import Record.Unsafe (unsafeSet)
import Routing.Hash (getHash, matches, setHash) import Routing.Hash (getHash, matches, setHash)
import Thermite (createClass)
import Thermite as T import Thermite as T
import Web.DOM.ParentNode (QuerySelector(..), querySelector) import Web.DOM.ParentNode (QuerySelector(..), querySelector)
import Web.HTML (window) import Web.HTML (window)
import Web.HTML.Window (document) 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 :: Effect Unit
main = do main = do
...@@ -25,13 +28,14 @@ main = do ...@@ -25,13 +28,14 @@ main = do
{ spec, dispatcher } -> void $ do { spec, dispatcher } -> void $ do
let setRouting this = void $ do let setRouting this = void $ do
matches routing (routeHandler (dispatchAction (dispatcher this))) matches routing (routeHandler (dispatchAction (dispatcher this)))
spec' = spec { componentWillMount = setRouting } spec' this = setComponentWillMount (setRouting this) <$> (spec this)
document <- window >>= document document <- window >>= document
container <- unsafePartial (fromJust <$> querySelector (QuerySelector "#app") (document)) container <- unsafePartial (fromJust <$> querySelector (QuerySelector "#app") (toParentNode document))
h <- getHash h <- getHash
case h of case h of
"" -> setHash "/" "" -> setHash "/"
_ -> do _ -> do
setHash "/" setHash "/"
setHash h 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