Module

Reactix.Hooks

Package
purescript-reactix
Repository
garganscript/purescript-reactix

#State Source

type State state = Tuple state ((state -> state) -> Effect Unit)

A state hook is a tuple of value and setter

#Setter Source

type Setter t = (t -> t) -> Effect Unit

#useState Source

useState :: forall s. (Unit -> s) -> Hooks (State s)

Given an Effect function returning an initial value, returns a State

#useState' Source

useState' :: forall s. s -> Hooks (State s)

#Reducer Source

type Reducer state action = Tuple state (action -> Effect Unit)

A reducer hook is a tuple of value and reducer-setter

#useReducer Source

useReducer :: forall s a i. (s -> a -> s) -> (i -> s) -> i -> Hooks (Reducer s a)

Given a reducer function from a state and action to a new state, an initialiser function and argument for the initialiser, returns a Reducer. Note args 2 and 3 are swapped in order from React.

#useReducer' Source

useReducer' :: forall s a. (s -> a -> s) -> s -> Hooks (Reducer s a)

Like useReducer, but takes an initial state instead of an initialiser function and argument

#useContext Source

useContext :: forall a. Context a -> Hooks a

Given a Context, returns its current value

#useRef Source

useRef :: forall r. r -> Hooks (Ref r)

#useDebugValue Source

useDebugValue :: forall v v'. v -> (v -> v') -> Hooks Unit

#useDebugValue' Source

useDebugValue' :: forall v. v -> Hooks Unit

#nothing Source

nothing :: Effect Unit

A cleanup handler that does nothing

#thenNothing Source

thenNothing :: forall a. Effect a -> Effect (Effect Unit)

Turns a simple effect function into an effect function that does nothing in cleanup after running

#useEffectOnce Source

useEffectOnce :: Effect (Effect Unit) -> Hooks Unit

Like useEffect, but runs only once in the lifecycle of the component The initial effect will be fired at mount and the cleanup effect will be fired at unmount

#useEffectOnce' Source

useEffectOnce' :: forall a. Effect a -> Hooks Unit

Like useEffectOnce, but the provided Effect fn does not return a cleanup handler

#useEffect Source

useEffect :: Effect (Effect Unit) -> Hooks Unit

Given an Effect function which returns a cleanup Effect function, register an effect to be called after rendering

#useEffect' Source

useEffect' :: forall a. Effect a -> Hooks Unit

Like useEffect, but the provided Effect fn does not return a cleanup handler

#useEffect1 Source

useEffect1 :: forall a. a -> Effect (Effect Unit) -> Hooks Unit

Like useEffect, but with a memo value

#useEffect1' Source

useEffect1' :: forall a b. a -> Effect b -> Hooks Unit

Like useEffect1, but the provided Effect fn does not return a cleanup handler

#useEffectFn1 Source

useEffectFn1 :: forall a. a -> (a -> Effect (Effect Unit)) -> Hooks Unit

Like useEffect1, but takes a function from memo value to effect

#useEffectFn1' Source

useEffectFn1' :: forall a. a -> (a -> Effect Unit) -> Hooks Unit

Like useEffect1', but takes a function from memo value to effect

#useEffect2 Source

useEffect2 :: forall a b. a -> b -> Effect (Effect Unit) -> Hooks Unit

Like useEffect, but with 2 memo values

#useEffect2' Source

useEffect2' :: forall a b c. a -> b -> Effect c -> Hooks Unit

Like useEffect2, but the provided Effect fn does not return a cleanup handler

#useEffectFn2 Source

useEffectFn2 :: forall a b. a -> b -> (a -> b -> Effect (Effect Unit)) -> Hooks Unit

like useEffectFn1, but with two memo values

#useEffectFn2' Source

useEffectFn2' :: forall a b. a -> b -> (a -> b -> Effect Unit) -> Hooks Unit

like useEffectFn1', but with two memo values

#useEffect3 Source

useEffect3 :: forall a b c. a -> b -> c -> Effect (Effect Unit) -> Hooks Unit

Like useEffect, but with 3 memo values

#useEffect3' Source

useEffect3' :: forall a b c d. a -> b -> c -> Effect d -> Hooks Unit

Like useEffect3, but the provided Effect fn does not return a cleanup handler

#useEffectFn3 Source

useEffectFn3 :: forall a b c. a -> b -> c -> (a -> b -> c -> Effect (Effect Unit)) -> Hooks Unit

like useEffectFn1, but with three memo values

#useEffectFn3' Source

useEffectFn3' :: forall a b c. a -> b -> c -> (a -> b -> c -> Effect Unit) -> Hooks Unit

like useEffectFn1', but with three memo values

#useEffect4 Source

useEffect4 :: forall a b c d. a -> b -> c -> d -> Effect (Effect Unit) -> Hooks Unit

Like useEffect, but with 4 memo values

#useEffect4' Source

useEffect4' :: forall a b c d e. a -> b -> c -> d -> Effect e -> Hooks Unit

Like useEffect4, but the provided Effect fn does not return a cleanup handler

#useEffectFn4 Source

useEffectFn4 :: forall a b c d. a -> b -> c -> d -> (a -> b -> c -> d -> Effect (Effect Unit)) -> Hooks Unit

like useEffectFn1, but with four memo values

#useEffectFn4' Source

useEffectFn4' :: forall a b c d. a -> b -> c -> d -> (a -> b -> c -> d -> Effect Unit) -> Hooks Unit

like useEffectFn1', but with four memo values

#useEffect5 Source

useEffect5 :: forall a b c d e. a -> b -> c -> d -> e -> Effect (Effect Unit) -> Hooks Unit

Like useEffect, but with 5 memo values

#useEffect5' Source

useEffect5' :: forall a b c d e f. a -> b -> c -> d -> e -> Effect f -> Hooks Unit

Like useEffect5, but the provided Effect fn does not return a cleanup handler

#useEffectFn5 Source

useEffectFn5 :: forall a b c d e. a -> b -> c -> d -> e -> (a -> b -> c -> d -> e -> Effect (Effect Unit)) -> Hooks Unit

like useEffectFn1, but with five memo values

#useEffectFn5' Source

useEffectFn5' :: forall a b c d e. a -> b -> c -> d -> e -> (a -> b -> c -> d -> e -> Effect Unit) -> Hooks Unit

like useEffectFn1', but with five memo values

#unsafeUseEffect Source

unsafeUseEffect :: forall a. Effect (Effect Unit) -> a -> Hooks Unit

Call React.useEffect passing an array-like object (arguments is acceptable) for memo values without any help from the type system to guarantee the memo value is in fact array-like.

#useLayoutEffect Source

useLayoutEffect :: Effect (Effect Unit) -> Hooks Unit

Given an Effect function which returns a cleanup Effect function, register an effect to be called in the same phase as componentDidMount and componentDidUpdate used to be.

#useLayoutEffect' Source

useLayoutEffect' :: forall a. Effect a -> Hooks Unit

Like useLayoutEffect, but the provided Effect fn does not return a cleanup handler

#useLayoutEffect1 Source

useLayoutEffect1 :: forall a. a -> Effect (Effect Unit) -> Hooks Unit

Like useLayoutEffect, but with a memo value

#useLayoutEffect1' Source

useLayoutEffect1' :: forall a b. a -> Effect b -> Hooks Unit

Like useLayoutEffect1, but the provided Effect fn does not return a cleanup handler

#useLayoutEffectFn1 Source

useLayoutEffectFn1 :: forall a. a -> (a -> Effect (Effect Unit)) -> Hooks Unit

Like useLayoutEffect1, but takes a function from memo value to effect

#useLayoutEffectFn1' Source

useLayoutEffectFn1' :: forall a. a -> (a -> Effect Unit) -> Hooks Unit

Like useLayoutEffect1, but takes a function from memo value to effect

#useLayoutEffect2 Source

useLayoutEffect2 :: forall a b. a -> b -> Effect (Effect Unit) -> Hooks Unit

Like useLayoutEffect, but with 2 memo values

#useLayoutEffect2' Source

useLayoutEffect2' :: forall a b c. a -> b -> Effect c -> Hooks Unit

Like useLayoutEffect1' but with 2 memo values

#useLayoutEffectFn2 Source

useLayoutEffectFn2 :: forall a b. a -> b -> (a -> b -> Effect (Effect Unit)) -> Hooks Unit

like useLayoutEffectFn1, but with two memo values

#useLayoutEffectFn2' Source

useLayoutEffectFn2' :: forall a b. a -> b -> (a -> b -> Effect Unit) -> Hooks Unit

like useLayoutEffectFn1', but with two memo values

#useLayoutEffect3 Source

useLayoutEffect3 :: forall a b c. a -> b -> c -> Effect (Effect Unit) -> Hooks Unit

Like useLayoutEffect, but with 3 memo values

#useLayoutEffect3' Source

useLayoutEffect3' :: forall a b c d. a -> b -> c -> Effect d -> Hooks Unit

Like useLayoutEffect1' but with 3 memo values

#useLayoutEffectFn3 Source

useLayoutEffectFn3 :: forall a b c. a -> b -> c -> (a -> b -> c -> Effect (Effect Unit)) -> Hooks Unit

like useLayoutEffectFn1, but with three memo values

#useLayoutEffectFn3' Source

useLayoutEffectFn3' :: forall a b c. a -> b -> c -> (a -> b -> c -> Effect Unit) -> Hooks Unit

like useLayoutEffectFn1', but with three memo values

#useLayoutEffect4 Source

useLayoutEffect4 :: forall a b c d. a -> b -> c -> d -> Effect (Effect Unit) -> Hooks Unit

Like useLayoutEffect, but with 4 memo values

#useLayoutEffect4' Source

useLayoutEffect4' :: forall a b c d e. a -> b -> c -> d -> Effect e -> Hooks Unit

Like useLayoutEffect1' but with 4 memo values

#useLayoutEffectFn4 Source

useLayoutEffectFn4 :: forall a b c d. a -> b -> c -> d -> (a -> b -> c -> d -> Effect (Effect Unit)) -> Hooks Unit

like useLayoutEffectFn1, but with four memo values

#useLayoutEffectFn4' Source

useLayoutEffectFn4' :: forall a b c d. a -> b -> c -> d -> (a -> b -> c -> d -> Effect Unit) -> Hooks Unit

like useLayoutEffectFn1', but with four memo values

#useLayoutEffect5 Source

useLayoutEffect5 :: forall a b c d e. a -> b -> c -> d -> e -> Effect (Effect Unit) -> Hooks Unit

Like useLayoutEffect, but with 5 memo values

#useLayoutEffect5' Source

useLayoutEffect5' :: forall a b c d e f. a -> b -> c -> d -> e -> Effect f -> Hooks Unit

Like useLayoutEffect1' but with 5 memo values

#useLayoutEffectFn5 Source

useLayoutEffectFn5 :: forall a b c d e. a -> b -> c -> d -> e -> (a -> b -> c -> d -> e -> Effect (Effect Unit)) -> Hooks Unit

like useLayoutEffectFn1, but with five memo values

#useLayoutEffectFn5' Source

useLayoutEffectFn5' :: forall a b c d e. a -> b -> c -> d -> e -> (a -> b -> c -> d -> e -> Effect Unit) -> Hooks Unit

like useLayoutEffectFn1', but with five memo values

#unsafeUseLayoutEffect Source

unsafeUseLayoutEffect :: forall a. Effect (Effect Unit) -> a -> Hooks Unit

Call React.useLayoutEffect passing an array-like object (arguments is acceptable) for memo values without any help from the type system to guarantee the memo value is in fact array-like.

#useMemo Source

useMemo :: forall t. (Unit -> t) -> Hooks t

Given a function to compute an expensive value, returns the value

#useMemo1 Source

useMemo1 :: forall a t. a -> (Unit -> t) -> Hooks t

Like useMemo but takes a memo value

#useMemo2 Source

useMemo2 :: forall a b t. a -> b -> (Unit -> t) -> Hooks t

Like useMemo but takes 2 memo values

#useMemo3 Source

useMemo3 :: forall a b c t. a -> b -> c -> (Unit -> t) -> Hooks t

Like useMemo but takes 3 memo values

#useMemo4 Source

useMemo4 :: forall a b c d t. a -> b -> c -> d -> (Unit -> t) -> Hooks t

Like useMemo but takes 4 memo values

#useMemo5 Source

useMemo5 :: forall a b c d e t. a -> b -> c -> d -> e -> (Unit -> t) -> Hooks t

Like useMemo but takes 5 memo values

#unsafeUseMemo Source

unsafeUseMemo :: forall t a. (Unit -> t) -> a -> Hooks t

Call React.useMemo passing an array-like object (arguments is acceptable) for memo values without any help from the type system to guarantee the memo value is in fact array-like.

#useCallback Source

useCallback :: forall t. (Unit -> t) -> Hooks (Effect t)

Given a function to compute an expensive value, returns the value

#useCallback1 Source

useCallback1 :: forall a t. a -> (Unit -> t) -> Hooks (Effect t)

Like useCallback but takes a memo value

#useCallback2 Source

useCallback2 :: forall a b t. a -> b -> (Unit -> t) -> Hooks (Effect t)

Like useCallback but takes 2 memo values

#useCallback3 Source

useCallback3 :: forall a b c t. a -> b -> c -> (Unit -> t) -> Hooks (Effect t)

Like useCallback but takes 3 memo values

#useCallback4 Source

useCallback4 :: forall a b c d t. a -> b -> c -> d -> (Unit -> t) -> Hooks (Effect t)

Like useCallback but takes 4 memo values

#useCallback5 Source

useCallback5 :: forall a b c d e t. a -> b -> c -> d -> e -> (Unit -> t) -> Hooks (Effect t)

Like useCallback but takes 5 memo values

#unsafeUseCallback Source

unsafeUseCallback :: forall t a. (Unit -> t) -> a -> Hooks (Effect t)

Call React.useCallback passing an array-like object (arguments is acceptable) for memo values without any help from the type system to guarantee the memo value is in fact array-like.

#useImperativeHandle Source

useImperativeHandle :: forall r r'. Ref r -> Effect r' -> Hooks Unit

#useImperativeHandle1 Source

useImperativeHandle1 :: forall a r r'. a -> Ref r -> Effect r' -> Hooks Unit

#useImperativeHandle2 Source

useImperativeHandle2 :: forall a b r r'. a -> b -> Ref r -> Effect r' -> Hooks Unit

#useImperativeHandle3 Source

useImperativeHandle3 :: forall a b c r r'. a -> b -> c -> Ref r -> Effect r' -> Hooks Unit

#useImperativeHandle4 Source

useImperativeHandle4 :: forall a b c d r r'. a -> b -> c -> d -> Ref r -> Effect r' -> Hooks Unit

#useImperativeHandle5 Source

useImperativeHandle5 :: forall a b c d e r r'. a -> b -> c -> d -> e -> Ref r -> Effect r' -> Hooks Unit

#unsafeUseImperativeHandle Source

unsafeUseImperativeHandle :: forall r r' a. Ref r -> Effect r' -> a -> Hooks Unit

Call React.useImperativeHandle passing an array-like object (arguments is acceptable) for memo values without any help from the type system to guarantee the memo value is in fact array-like.