You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`@cdoublev/react-utils` is built with the current NodeJS version as target, meaning that it should probably be transpiled in order to be used in your application using its own targets.
26
34
27
-
***
35
+
## API
28
36
29
-
**(Hooks)**
37
+
### Hooks
30
38
31
-
## useAnimate
39
+
####useAnimate
32
40
33
41
`useAnimate` abstracts using `Element.animate()` from the Web Animation API ([MDN](https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API)).
34
42
@@ -42,7 +50,7 @@ This package contains common hooks and components to use in a React application.
`useAnimateCustom` abstracts using `animate()`, a lightweight alternative to [`Element.animate()`](https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API) or its [official polyfill](https://github.com/web-animations/web-animations-js), with some [extra features](https://github.com/creativewave/animate#extra-features).
`useIntersectionObserver` abstracts using an `IntersectionObserver` to execute a function when an `Element` intersects an ancestor, ie. when it enters in or exits from its viewport.
69
77
@@ -86,7 +94,7 @@ Each observed `Element` will be unobserved before unmount, and the current `Inte
86
94
87
95
**Note:** make sure to use a memoized value for `threshold` if it's an `Array`, as well as for `onEnter` and `onExit`.
@@ -99,7 +107,7 @@ It will stop executing `Function` if:
99
107
- the reference to `Function` has changed
100
108
- the delay (`Number`) has changed
101
109
102
-
## useGatherMemo
110
+
####useGatherMemo
103
111
104
112
`useGatherMemo` abstracts gathering (merging) and/or picking (destructuring) properties from object(s) while memoizing the result to avoid unneeded updates in the component and its children.
**Warning:** don't over use it, ie. use it only with large objects, otherwise it will negatively impact performances by increasing the call stack as well as the amount of data stored in memory.
141
149
142
-
## useLazyStateUpdate
150
+
####useLazyStateUpdate
143
151
144
152
`useLazyStateUpdate` abstracts delaying a state update.
145
153
@@ -149,13 +157,13 @@ It could be used eg. to delay the render of an error notice after validating an
149
157
150
158
`useLazyStateUpdate :: [a, Number] -> a`
151
159
152
-
## useMediaQuery
160
+
####useMediaQuery
153
161
154
162
`useMediaQuery` abstracts using `windows.matchMedia()` to observe a match against a query, eg. `(min-width: 50em)`.
155
163
156
164
`useMediaQuery :: String -> Boolean`
157
165
158
-
## useScrollIntoView
166
+
####useScrollIntoView
159
167
160
168
`useScrollIntoView` abstracts using `Element.scrollIntoView()` when a `scroll` event is emitted.
161
169
@@ -187,7 +195,7 @@ Both should be used. To set `document` as `root`, the corresponding callback ref
187
195
-`onEnter` and `onExit` are optional callbacks defined in [`useIntersectionObserver`](#useIntersectionObserver)
188
196
-`touchSensitivity` (default to `150`) is a distance in pixels that the finger or stylus should move to be handled as a scroll event
189
197
190
-
## useSVGMousePosition
198
+
####useSVGMousePosition
191
199
192
200
`useSVGMousePosition` abstracts translating the position of the mouse relative to an `<svg>` in `document`, into a position relative to its `viewBox`.
193
201
@@ -210,7 +218,7 @@ The first [`CallbackRef`](https://reactjs.org/docs/refs-and-the-dom.html#callbac
210
218
-`isFixed` (default to `false`) is an optional `Boolean` to flag the `target` as having a fixed position in the viewport of `document`, ie. in `window`
211
219
-`precision` (default to `2`) is an optional number to round `Position` values
212
220
213
-
## useTimeout
221
+
####useTimeout
214
222
215
223
`useTimeout` abstracts using `setTimeout()` and `clearTimeout()` to schedule the execution of a `Function`, without worrying about cancelling the timer to avoid a memory leak such as *a React state update on an unmounted component*.
216
224
@@ -221,7 +229,7 @@ It will stop executing `Function` if:
221
229
- the reference to `Function` has changed
222
230
- the delay (`Number`) has changed
223
231
224
-
## useTransition
232
+
####useTransition
225
233
226
234
`useTransition` abstracts scheduling multiple state updates over time using different delays and durations.
-[React Spring (useTransition)](https://www.react-spring.io/docs/hooks/use-transition)
243
251
244
-
## useValidation
252
+
####useValidation
245
253
246
254
`useValidation` abstracts using the Constraint Validation API ([MDN](https://developer.mozilla.org/en-US/docs/Web/API/Constraint_validation)) to validate a form field on blur (default) or on change.
It returns any error message from the Constraint Validation API, and a collection of component properties such as `onChange` and `onBlur` event handlers, to assign to an `<input>`, `<select>` or `<textarea>`. Each of those handlers will be composed with a corresponding handler given as argument.
251
259
252
-
***
253
-
254
-
**(Components)**
260
+
### Components
255
261
256
-
## Filter
262
+
####Filter
257
263
258
264
`<Filter>` provides common filter effects to use in a `SVGElement`.
0 commit comments