Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@restart/hooks

Package Overview
Dependencies
Maintainers
2
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@restart/hooks - npm Package Compare versions

Comparing version 0.3.22 to 0.3.23

2

cjs/globals.d.ts

@@ -56,3 +56,3 @@ interface Window {

interface DOMRectReadOnly {
static fromRect(other: DOMRectInit | undefined): DOMRectReadOnly
fromRect(other: DOMRectInit | undefined): DOMRectReadOnly

@@ -59,0 +59,0 @@ readonly x: number

@@ -21,2 +21,6 @@ /// <reference types="react" />

}
export interface FocusController {
onBlur: (event: any) => void;
onFocus: (event: any) => void;
}
/**

@@ -28,3 +32,3 @@ * useFocusManager provides a way to track and manage focus as it moves around

*
* ```ts
* ```tsx
* const [focused, setFocusState] = useState(false)

@@ -46,8 +50,3 @@ *

*
* @param opts Options
* @returns FocusController a set of paired focus and blur event handlers
*/
export default function useFocusManager(opts: FocusManagerOptions): {
onBlur: (event: any) => void;
onFocus: (event: any) => void;
};
export default function useFocusManager(opts: FocusManagerOptions): FocusController;

@@ -8,6 +8,6 @@ "use strict";

var _useEventCallback = _interopRequireDefault(require("./useEventCallback"));
var _useMounted = _interopRequireDefault(require("./useMounted"));
var _useEventCallback = _interopRequireDefault(require("./useEventCallback"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -21,3 +21,3 @@

*
* ```ts
* ```tsx
* const [focused, setFocusState] = useState(false)

@@ -39,4 +39,2 @@ *

*
* @param opts Options
* @returns FocusController a set of paired focus and blur event handlers
*/

@@ -43,0 +41,0 @@ function useFocusManager(opts) {

/**
* Creates a `setInterval` that is properly cleaned up when a component unmounted
*
* ```tsx
* function Timer() {
* const [timer, setTimer] = useState(0)
* useInterval(() => setTimer(i => i + 1), 1000)
*
* return <span>{timer} seconds past</span>
* }
* ```
*
* @param fn an function run on each interval

@@ -11,2 +20,17 @@ * @param ms The milliseconds duration of the interval

*
* ```tsx
* const [paused, setPaused] = useState(false)
* const [timer, setTimer] = useState(0)
*
* useInterval(() => setTimer(i => i + 1), 1000, paused)
*
* return (
* <span>
* {timer} seconds past
*
* <button onClick={() => setPaused(p => !p)}>{paused ? 'Play' : 'Pause' }</button>
* </span>
* )
* ```
*
* @param fn an function run on each interval

@@ -18,4 +42,13 @@ * @param ms The milliseconds duration of the interval

/**
* Creates a pausable `setInterval` that is properly cleaned up when a component unmounted
* Creates a pausable `setInterval` that _fires_ immediately and is
* properly cleaned up when a component unmounted
*
* ```tsx
* const [timer, setTimer] = useState(-1)
* useInterval(() => setTimer(i => i + 1), 1000, false, true)
*
* // will update to 0 on the first effect
* return <span>{timer} seconds past</span>
* ```
*
* @param fn an function run on each interval

@@ -26,4 +59,6 @@ * @param ms The milliseconds duration of the interval

* rather than waiting for the first interval to elapse
*
*/
declare function useInterval(fn: () => void, ms: number, paused: boolean, runImmediately: boolean): void;
export default useInterval;

@@ -21,3 +21,3 @@ declare type Updater<TState> = (state: TState) => Partial<TState> | null;

*/
export default function useMergeState<TState extends {}>(initialState: TState): [TState, MergeStateSetter<TState>];
export default function useMergeState<TState extends {}>(initialState: TState | (() => TState)): [TState, MergeStateSetter<TState>];
export {};

@@ -56,3 +56,3 @@ interface Window {

interface DOMRectReadOnly {
static fromRect(other: DOMRectInit | undefined): DOMRectReadOnly
fromRect(other: DOMRectInit | undefined): DOMRectReadOnly

@@ -59,0 +59,0 @@ readonly x: number

@@ -21,2 +21,6 @@ /// <reference types="react" />

}
export interface FocusController {
onBlur: (event: any) => void;
onFocus: (event: any) => void;
}
/**

@@ -28,3 +32,3 @@ * useFocusManager provides a way to track and manage focus as it moves around

*
* ```ts
* ```tsx
* const [focused, setFocusState] = useState(false)

@@ -46,8 +50,3 @@ *

*
* @param opts Options
* @returns FocusController a set of paired focus and blur event handlers
*/
export default function useFocusManager(opts: FocusManagerOptions): {
onBlur: (event: any) => void;
onFocus: (event: any) => void;
};
export default function useFocusManager(opts: FocusManagerOptions): FocusController;
import { useCallback, useRef } from 'react';
import useEventCallback from './useEventCallback';
import useMounted from './useMounted';
import useEventCallback from './useEventCallback';

@@ -11,3 +11,3 @@ /**

*
* ```ts
* ```tsx
* const [focused, setFocusState] = useState(false)

@@ -29,4 +29,2 @@ *

*
* @param opts Options
* @returns FocusController a set of paired focus and blur event handlers
*/

@@ -33,0 +31,0 @@ export default function useFocusManager(opts) {

/**
* Creates a `setInterval` that is properly cleaned up when a component unmounted
*
* ```tsx
* function Timer() {
* const [timer, setTimer] = useState(0)
* useInterval(() => setTimer(i => i + 1), 1000)
*
* return <span>{timer} seconds past</span>
* }
* ```
*
* @param fn an function run on each interval

@@ -11,2 +20,17 @@ * @param ms The milliseconds duration of the interval

*
* ```tsx
* const [paused, setPaused] = useState(false)
* const [timer, setTimer] = useState(0)
*
* useInterval(() => setTimer(i => i + 1), 1000, paused)
*
* return (
* <span>
* {timer} seconds past
*
* <button onClick={() => setPaused(p => !p)}>{paused ? 'Play' : 'Pause' }</button>
* </span>
* )
* ```
*
* @param fn an function run on each interval

@@ -18,4 +42,13 @@ * @param ms The milliseconds duration of the interval

/**
* Creates a pausable `setInterval` that is properly cleaned up when a component unmounted
* Creates a pausable `setInterval` that _fires_ immediately and is
* properly cleaned up when a component unmounted
*
* ```tsx
* const [timer, setTimer] = useState(-1)
* useInterval(() => setTimer(i => i + 1), 1000, false, true)
*
* // will update to 0 on the first effect
* return <span>{timer} seconds past</span>
* ```
*
* @param fn an function run on each interval

@@ -26,4 +59,6 @@ * @param ms The milliseconds duration of the interval

* rather than waiting for the first interval to elapse
*
*/
declare function useInterval(fn: () => void, ms: number, paused: boolean, runImmediately: boolean): void;
export default useInterval;

@@ -6,2 +6,11 @@ import { useEffect } from 'react';

*
* ```tsx
* function Timer() {
* const [timer, setTimer] = useState(0)
* useInterval(() => setTimer(i => i + 1), 1000)
*
* return <span>{timer} seconds past</span>
* }
* ```
*
* @param fn an function run on each interval

@@ -8,0 +17,0 @@ * @param ms The milliseconds duration of the interval

@@ -21,3 +21,3 @@ declare type Updater<TState> = (state: TState) => Partial<TState> | null;

*/
export default function useMergeState<TState extends {}>(initialState: TState): [TState, MergeStateSetter<TState>];
export default function useMergeState<TState extends {}>(initialState: TState | (() => TState)): [TState, MergeStateSetter<TState>];
export {};
{
"name": "@restart/hooks",
"version": "0.3.22",
"version": "0.3.23",
"main": "cjs/index.js",

@@ -5,0 +5,0 @@ "types": "cjs/index.d.ts",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc