diff --git a/snippets/useLocalStorage.md b/snippets/useLocalStorage.md index 58aacc882..1a94c83b2 100644 --- a/snippets/useLocalStorage.md +++ b/snippets/useLocalStorage.md @@ -7,7 +7,7 @@ firstSeen: 2021-09-13T05:00:00-04:00 Creates a stateful value that is persisted to `localStorage`, and a function to update it. - Use the `useState()` hook with a function to initialize its value lazily. -- Use a `try...catch` block and `Storage.getItem()` to try and get the value from `localStorage`. If no value is found, use `Storage.setItem()` to store the `defaultValue` and use it as the initial state. If an error occurs, use `defaultValue` as the initial state. +- Use a `try...catch` block and `Storage.getItem()` to try and get the value from `Window.localStorage`. If no value is found, use `Storage.setItem()` to store the `defaultValue` and use it as the initial state. If an error occurs, use `defaultValue` as the initial state. - Define a function that will update the state variable with the passed value and use `Storage.setItem()` to store it. ```jsx diff --git a/snippets/useMediaQuery.md b/snippets/useMediaQuery.md index f83f8e2b1..263c28cc0 100644 --- a/snippets/useMediaQuery.md +++ b/snippets/useMediaQuery.md @@ -7,8 +7,8 @@ lastUpdated: 2021-10-13T19:29:39+02:00 Checks if the current environment matches a given media query and returns the appropriate value. -- Check if `window` and `window.matchMedia` exist. Return `whenFalse` if not (e.g. SSR environment or unsupported browser). -- Use `window.matchMedia()` to match the given `query`. Cast its `matches` property to a boolean and store in a state variable, `match`, using the `useState()` hook. +- Check if `Window` and `Window.matchMedia()` exist. Return `whenFalse` if not (e.g. SSR environment or unsupported browser). +- Use `Window.matchMedia()` to match the given `query`. Cast its `matches` property to a boolean and store in a state variable, `match`, using the `useState()` hook. - Use the `useEffect()` hook to add a listener for changes and to clean up the listeners after the hook is destroyed. - Return either `whenTrue` or `whenFalse` based on the value of `match`. diff --git a/snippets/useNavigatorOnLine.md b/snippets/useNavigatorOnLine.md index 05b17c216..9e46111b5 100644 --- a/snippets/useNavigatorOnLine.md +++ b/snippets/useNavigatorOnLine.md @@ -7,7 +7,7 @@ lastUpdated: 2020-11-16T14:17:53+02:00 Checks if the client is online or offline. -- Create a function, `getOnLineStatus`, that uses the `NavigatorOnLine` web API to get the online status of the client. +- Create a function, `getOnLineStatus`, that uses the `Navigator.onLine` web API to get the online status of the client. - Use the `useState()` hook to create an appropriate state variable, `status`, and setter. - Use the `useEffect()` hook to add listeners for appropriate events, updating state, and cleanup those listeners when unmounting. - Finally return the `status` state variable. diff --git a/snippets/useOnGlobalEvent.md b/snippets/useOnGlobalEvent.md index 89e50a701..dc915d649 100644 --- a/snippets/useOnGlobalEvent.md +++ b/snippets/useOnGlobalEvent.md @@ -8,7 +8,7 @@ Executes a callback whenever an event occurs on the global object. - Use the `useRef()` hook to create a variable, `listener`, which will hold the listener reference. - Use the `useRef()` hook to create a variable that will hold the previous values of the `type` and `options` arguments. -- Use the `useEffect()` hook and `EventTarget.addEventListener()` to listen to the given event `type` on the `window` global object. +- Use the `useEffect()` hook and `EventTarget.addEventListener()` to listen to the given event `type` on the `Window` global object. - Use `EventTarget.removeEventListener()` to remove any existing listeners and clean up when the component unmounts. ```jsx diff --git a/snippets/useOnWindowResize.md b/snippets/useOnWindowResize.md index 4c6013007..4f453669c 100644 --- a/snippets/useOnWindowResize.md +++ b/snippets/useOnWindowResize.md @@ -7,7 +7,7 @@ firstSeen: 2021-12-01T05:00:00-04:00 Executes a callback whenever the window is resized. - Use the `useRef()` hook to create a variable, `listener`, which will hold the listener reference. -- Use the `useEffect()` hook and `EventTarget.addEventListener()` to listen to the `'resize'` event of the `window` global object. +- Use the `useEffect()` hook and `EventTarget.addEventListener()` to listen to the `'resize'` event of the `Window` global object. - Use `EventTarget.removeEventListener()` to remove any existing listeners and clean up when the component unmounts. ```jsx diff --git a/snippets/useOnWindowScroll.md b/snippets/useOnWindowScroll.md index f7d648c57..725c0446c 100644 --- a/snippets/useOnWindowScroll.md +++ b/snippets/useOnWindowScroll.md @@ -7,7 +7,7 @@ firstSeen: 2021-12-08T05:00:00-04:00 Executes a callback whenever the window is scrolled. - Use the `useRef()` hook to create a variable, `listener`, which will hold the listener reference. -- Use the `useEffect()` hook and `EventTarget.addEventListener()` to listen to the `'scroll'` event of the `window` global object. +- Use the `useEffect()` hook and `EventTarget.addEventListener()` to listen to the `'scroll'` event of the `Window` global object. - Use `EventTarget.removeEventListener()` to remove any existing listeners and clean up when the component unmounts. ```jsx