File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,17 @@ function readState(this_) {
6060}
6161exports . readState = readState ;
6262
63+ function transformState ( this_ ) {
64+ return function ( update ) {
65+ return function ( ) {
66+ this_ . setState ( function ( old , props ) {
67+ return { state : update ( old . state ) } ;
68+ } ) ;
69+ } ;
70+ } ;
71+ }
72+ exports . transformState = transformState ;
73+
6374function createClass ( spec ) {
6475 var result = {
6576 displayName : spec . displayName ,
Original file line number Diff line number Diff line change @@ -285,10 +285,7 @@ foreign import writeState :: forall props state access eff. ReactThis props stat
285285foreign import readState :: forall props state access eff . ReactThis props state -> Eff (state :: ReactState (read :: Read | access ) | eff ) state
286286
287287-- | Transform the component state by applying a function.
288- transformState :: forall props state eff . ReactThis props state -> (state -> state ) -> Eff (state :: ReactState ReadWrite | eff ) state
289- transformState ctx f = do
290- state <- readState ctx
291- writeState ctx $ f state
288+ foreign import transformState :: forall props state eff . ReactThis props state -> (state -> state ) -> Eff (state :: ReactState ReadWrite | eff ) Unit
292289
293290-- | Create a React class from a specification.
294291foreign import createClass :: forall props state eff . ReactSpec props state eff -> ReactClass props
You can’t perform that action at this time.
0 commit comments