File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 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
77 , ReactChildren
88 , memo
99 , useState
10+ , useState'
1011 , UseState
1112 , useEffect
1213 , useEffectOnce
@@ -39,6 +40,7 @@ module React.Basic.Hooks
3940 ) where
4041
4142import Prelude hiding (bind , discard )
43+ import Data.Bifunctor (rmap )
4244import Data.Function.Uncurried (Fn2 , mkFn2 )
4345import Data.Maybe (Maybe )
4446import Data.Newtype (class Newtype )
@@ -165,6 +167,13 @@ useState initialState =
165167 unsafeHook do
166168 runEffectFn2 useState_ (mkFn2 Tuple ) initialState
167169
170+ useState' ::
171+ forall state .
172+ state ->
173+ Hook (UseState state ) (state /\ (state -> Effect Unit ))
174+ useState' initialState =
175+ useState initialState <#> rmap (_ <<< const)
176+
168177foreign import data UseState :: Type -> Type -> Type
169178
170179-- | 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