@@ -5,21 +5,21 @@ import Prelude
55import Data.Array ((!!), drop , mapWithIndex , take )
66import Data.Foldable (for_ )
77import Data.Maybe (Maybe (Nothing), fromMaybe , maybe )
8- import React.Basic ( ReactComponent , createElement , fragment , react )
8+ import React.Basic as React
99import React.Basic.DOM as R
1010import React.Basic.DOM.Events (targetChecked )
1111import React.Basic.Events as Events
1212import React.Basic.ReactDND (DragDrop , DragDropContextProps , DragDropItemType (..), createDragDrop , createDragDropContext )
1313import React.Basic.ReactDND.Backends.HTML5Backend (html5Backend )
1414
15- dndContext :: ReactComponent DragDropContextProps
15+ dndContext :: React.Component DragDropContextProps
1616dndContext = createDragDropContext html5Backend
1717
1818dnd :: DragDrop { itemId :: String , index :: Int }
1919dnd = createDragDrop (DragDropItemType " TODO_ITEM" )
2020
21- component :: ReactComponent { }
22- component = react { displayName: " BasicExample" , initialState, receiveProps, render }
21+ component :: React.Component { }
22+ component = React .component { displayName: " BasicExample" , initialState, receiveProps, render }
2323 where
2424 initialState =
2525 { todos:
@@ -29,22 +29,22 @@ component = react { displayName: "BasicExample", initialState, receiveProps, ren
2929 ]
3030 }
3131
32- receiveProps _ _ _ =
32+ receiveProps _ =
3333 pure unit
3434
35- render _ state setState =
36- createElement dndContext
35+ render { state, setState } =
36+ React .element dndContext
3737 { child:
38- fragment
38+ React . fragment
3939 [ R .h1_ [ R .text " Todos" ]
4040 , R .p_ [ R .text " Drag to reorder the list:" ]
4141 , R .section_ (mapWithIndex renderTodo state.todos)
4242 ]
4343 }
4444
4545 where
46- renderTodo index todo =
47- createElement dnd.dragSource
46+ renderTodo index todo =
47+ React .element dnd.dragSource
4848 { beginDrag: \_ -> pure
4949 { itemId: todo.id
5050 , index
@@ -54,7 +54,7 @@ component = react { displayName: "BasicExample", initialState, receiveProps, ren
5454 , isDragging: \{ item: draggingItem } ->
5555 pure $ maybe false (\i -> i.itemId == todo.id) draggingItem
5656 , render: \{ connectDragSource, isDragging } ->
57- createElement dnd.dropTarget
57+ React .element dnd.dropTarget
5858 { drop: \{ item: dragItem } -> do
5959 for_ (_.index <$> dragItem) \dragItemIndex ->
6060 setState \s -> s
0 commit comments