@proscom/ui-react
Advanced tools
Comparing version 0.1.8 to 0.1.9
@@ -1,2 +0,2 @@ | ||
import { useRef, useState } from 'react'; | ||
import { useCallback, useRef, useState } from 'react'; | ||
/** | ||
@@ -23,3 +23,3 @@ * Хук, который позволяет при зависимости стейта от пропов | ||
var stateRef = useRef(targetValue); | ||
var setState = function (value) { | ||
var setState = useCallback(function (value) { | ||
stateRef.current = | ||
@@ -30,3 +30,3 @@ typeof value === 'function' | ||
rerender(function (s) { return s + 1; }); | ||
}; | ||
}, []); | ||
// Отслеживаем изменения targetValue и меняем стейт, если он меняется | ||
@@ -33,0 +33,0 @@ var previousValue = useRef(targetValue); |
@@ -40,2 +40,2 @@ /** | ||
*/ | ||
export declare function useLiveInput<Value>(onSubmit: (value: Value) => void, delay?: number): (boolean | ((value: Value, useTimeout?: boolean) => void))[]; | ||
export declare function useLiveInput<Value>(onSubmit: (value: Value) => void, delay?: number): readonly [boolean, (value: Value, useTimeout?: boolean) => void]; |
@@ -26,3 +26,3 @@ "use strict"; | ||
var stateRef = react_1.useRef(targetValue); | ||
var setState = function (value) { | ||
var setState = react_1.useCallback(function (value) { | ||
stateRef.current = | ||
@@ -33,3 +33,3 @@ typeof value === 'function' | ||
rerender(function (s) { return s + 1; }); | ||
}; | ||
}, []); | ||
// Отслеживаем изменения targetValue и меняем стейт, если он меняется | ||
@@ -36,0 +36,0 @@ var previousValue = react_1.useRef(targetValue); |
@@ -40,2 +40,2 @@ /** | ||
*/ | ||
export declare function useLiveInput<Value>(onSubmit: (value: Value) => void, delay?: number): (boolean | ((value: Value, useTimeout?: boolean) => void))[]; | ||
export declare function useLiveInput<Value>(onSubmit: (value: Value) => void, delay?: number): readonly [boolean, (value: Value, useTimeout?: boolean) => void]; |
{ | ||
"name": "@proscom/ui-react", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"description": "Proscom React utilities", | ||
@@ -46,4 +46,3 @@ "author": "Andrew Starostin <a.starostin@proscom.ru>", | ||
"rimraf": "^3.0.2" | ||
}, | ||
"gitHead": "ed7b4390de441e41fb4ae7330d0613cd2524ea13" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Dispatch, SetStateAction, useEffect, useRef, useState } from 'react'; | ||
import { SetStateAction, useCallback, useRef, useState } from 'react'; | ||
@@ -25,3 +25,3 @@ /** | ||
const stateRef = useRef<T>(targetValue); | ||
const setState = (value: SetStateAction<T>) => { | ||
const setState = useCallback((value: SetStateAction<T>) => { | ||
stateRef.current = | ||
@@ -32,3 +32,3 @@ typeof value === 'function' | ||
rerender((s) => s + 1); | ||
}; | ||
}, []); | ||
@@ -35,0 +35,0 @@ // Отслеживаем изменения targetValue и меняем стейт, если он меняется |
@@ -66,3 +66,3 @@ import { useCallback, useState } from "react"; | ||
return [isNewInput, handleSubmit]; | ||
return [isNewInput, handleSubmit] as const; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
145772