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
Copy file name to clipboardExpand all lines: README.md
+21-1Lines changed: 21 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,6 +53,7 @@ const DebouncedButton = () => {
53
53
*[`useIsMounted`](#useIsMounted): keep track of whether or not a component is mounted.
54
54
*[`useIsomorphicLayoutEffect`](#useIsomorphicLayoutEffect): use this instead of [`useLayoutEffect`](https://reactjs.org/docs/hooks-reference.html#uselayouteffect) if your app uses serverside rendering (SSR).
55
55
*[`useIsScrolling`](#useIsScrolling): keep track of whether or not the user is scrolling.
56
+
*[`useLang`](#useLang): use the browser's language setting.
56
57
*[`useOnScroll`](#useOnScroll): subscribe to scroll events.
57
58
*[`usePrevious`](#usePrevious): keep track of a variable's previous value.
58
59
*[`useWindowScroll`](#useWindowScroll): keep track of the `window`'s scroll position.
@@ -293,7 +294,7 @@ const MyComponent = () => {
293
294
294
295
Returns a `boolean` indicating whether or not the user is scrolling. You can subscribe to a specific element via the first argument, `el`_(default: `window`)_. End of scrolling is determined by no incoming scroll events for `scrollEndMs` milliseconds _(default: `100`)_. Please check the [example blow](#useIsScrollingExample) as well as the [Codepen example](https://codepen.io/haensl/pen/qBbqeWz)
Returns the user's language setting from [`navigator.language`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/language). Use the `defaultLang` of the options parameter to set a default language. _(default: `'en`)_.
317
+
318
+
##### Example <aname="useLangExample"></a>
319
+
320
+
```javascript
321
+
importReactfrom'react';
322
+
import { useLang } from'@haensl/react-hooks';
323
+
324
+
constMyComponent= () => {
325
+
constlang=useLang();
326
+
327
+
return (
328
+
<span>The user's preferred language is { lang }.</span>
Subscribes to [`scroll`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scroll_event) events on the given element `el` _(default: `window`)_. The callback function `fn` is passed the [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scroll_event). Please check the [example below](#useOnScrollExample) as well as the [Codepen example](https://codepen.io/haensl/pen/wvMoLJK).
0 commit comments