Skip to content

Commit eaecf65

Browse files
authored
Create Try.purs
1 parent ca78827 commit eaecf65

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module Thermite.Try where
2+
3+
import Prelude
4+
5+
import Control.Monad.Eff (Eff)
6+
import Data.Maybe (fromJust)
7+
import Data.Newtype (wrap)
8+
import DOM (DOM) as DOM
9+
import DOM.HTML (window) as DOM
10+
import DOM.HTML.Types (htmlDocumentToParentNode) as DOM
11+
import DOM.HTML.Window (document) as DOM
12+
import DOM.Node.ParentNode (querySelector) as DOM
13+
import Partial.Unsafe (unsafePartial)
14+
import React (createFactory) as R
15+
import ReactDOM (render) as R
16+
import Thermite as T
17+
18+
-- | The main method creates the task list component, and renders it to the document body.
19+
defaultMain :: forall state action eff. T.Spec eff state Unit action -> state -> Eff (dom :: DOM.DOM | eff) Unit
20+
defaultMain spec initialState = void do
21+
let component = T.createClass spec initialState
22+
document <- DOM.window >>= DOM.document
23+
container <- unsafePartial fromJust <$> DOM.querySelector (wrap "#app") (DOM.htmlDocumentToParentNode document)
24+
R.render (R.createFactory component unit) container

0 commit comments

Comments
 (0)