File tree 1 file changed +9
-0
lines changed
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ module React.Basic.Hooks
7
7
, ReactChildren
8
8
, memo
9
9
, useState
10
+ , useState'
10
11
, UseState
11
12
, useEffect
12
13
, useEffectOnce
@@ -39,6 +40,7 @@ module React.Basic.Hooks
39
40
) where
40
41
41
42
import Prelude hiding (bind , discard )
43
+ import Data.Bifunctor (rmap )
42
44
import Data.Function.Uncurried (Fn2 , mkFn2 )
43
45
import Data.Maybe (Maybe )
44
46
import Data.Newtype (class Newtype )
@@ -165,6 +167,13 @@ useState initialState =
165
167
unsafeHook do
166
168
runEffectFn2 useState_ (mkFn2 Tuple ) initialState
167
169
170
+ useState' ::
171
+ forall state .
172
+ state ->
173
+ Hook (UseState state ) (state /\ (state -> Effect Unit ))
174
+ useState' initialState =
175
+ useState initialState <#> rmap (_ <<< const)
176
+
168
177
foreign import data UseState :: Type -> Type -> Type
169
178
170
179
-- | Runs the given effect when the component is mounted and any time the given
You can’t perform that action at this time.
0 commit comments