Skip to content

Commit 0b047fd

Browse files
committed
React-Basic v5
1 parent f513d60 commit 0b047fd

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

Diff for: bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"dependencies": {
1010
"purescript-prelude": "^4.1.0",
11-
"purescript-react-basic": "^4.0.1",
11+
"purescript-react-basic": "^5.0.0",
1212
"purescript-nullable": "^4.0.0",
1313
"purescript-promises": "^3.0.0"
1414
},

Diff for: examples/basic/src/Basic.purs

+7-11
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Prelude
55
import Data.Array ((!!), drop, mapWithIndex, take)
66
import Data.Foldable (for_)
77
import Data.Maybe (Maybe(Nothing), fromMaybe, maybe)
8-
import React.Basic (Component, JSX, StateUpdate(..), createComponent, fragment, make)
8+
import React.Basic (Component, JSX, StateUpdate(..), createComponent, fragment, make, send)
99
import React.Basic.DOM as R
1010
import React.Basic.DOM.Events (targetChecked)
1111
import React.Basic.Events as Events
@@ -22,15 +22,11 @@ data Action
2222
= Move { from :: Int, to :: Int }
2323
| SetDone String Boolean
2424

25-
component :: Component
25+
component :: Component Unit
2626
component = createComponent "TodoExample"
2727

2828
todoExample :: JSX
29-
todoExample = unit # make component
30-
{ initialState = initialState
31-
, update = update
32-
, render = render
33-
}
29+
todoExample = unit # make component { initialState, update, render }
3430
where
3531
initialState =
3632
{ todos:
@@ -52,12 +48,12 @@ todoExample = unit # make component
5248
else t
5349
}
5450

55-
render { state, send } =
51+
render self =
5652
dndContext $
5753
fragment
5854
[ R.h1_ [ R.text "Todos" ]
5955
, R.p_ [ R.text "Drag to reorder the list:" ]
60-
, R.section_ (mapWithIndex renderTodo state.todos)
56+
, R.section_ (mapWithIndex renderTodo self.state.todos)
6157
]
6258

6359
where
@@ -75,7 +71,7 @@ todoExample = unit # make component
7571
dnd.dropTarget
7672
{ drop: \{ item: dragItem } -> do
7773
for_ (_.index <$> dragItem) \dragItemIndex ->
78-
send $ Move { from: dragItemIndex, to: index }
74+
send self $ Move { from: dragItemIndex, to: index }
7975
pure Nothing
8076
, hover: const (pure unit)
8177
, canDrop: const (pure true)
@@ -100,7 +96,7 @@ todoExample = unit # make component
10096
{ "type": "checkbox"
10197
, checked: todo.done
10298
, onChange: Events.handler targetChecked \checked -> do
103-
send $ SetDone todo.id $ fromMaybe false checked
99+
send self $ SetDone todo.id $ fromMaybe false checked
104100
}
105101
, R.text todo.text
106102
]

0 commit comments

Comments
 (0)