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

react-hooks-library

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-hooks-library - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

4

dist/hooks/useQuery.d.ts

@@ -8,2 +8,4 @@ export interface IQueryProps<P> {

query?(params?: IQueryProps<P>['variable']): Promise<P>;
onSuccess?(result: P): void;
onFailure?(error: Error): void;
}

@@ -15,5 +17,5 @@ export declare function useQuery<P>(props: IQueryProps<P>): {

error: any;
refetch: (variable?: object | undefined) => Promise<P | undefined>;
refetch: (variable?: object | undefined) => Promise<any>;
startPolling: (interval: number) => void;
stopPolling: () => void;
};

@@ -38,27 +38,29 @@ import * as tslib_1 from "tslib";

return tslib_1.__awaiter(_this, void 0, void 0, function () {
var response;
var response, error_1;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!mergedProps.query) return [3 /*break*/, 2];
if (!mergedProps.query) return [3 /*break*/, 4];
setLoading(true);
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, mergedProps.query(variable)];
case 1:
case 2:
response = _a.sent();
try {
if (response) {
setData(response);
}
else {
reset();
}
setLoading(false);
return [2 /*return*/, response];
if (response) {
setData(response);
}
catch (error) {
setError(error);
return [2 /*return*/, response];
else {
reset();
}
_a.label = 2;
case 2: return [2 /*return*/, undefined];
setLoading(false);
typeof props.onSuccess === 'function' && props.onSuccess(response);
return [2 /*return*/, response];
case 3:
error_1 = _a.sent();
setError(error_1);
typeof props.onFailure === 'function' && props.onFailure(error_1);
return [2 /*return*/, error_1];
case 4: return [2 /*return*/, undefined];
}

@@ -65,0 +67,0 @@ });

{
"name": "react-hooks-library",
"version": "0.0.11",
"version": "0.0.12",
"license": "MIT",

@@ -5,0 +5,0 @@ "scripts": {

@@ -13,2 +13,4 @@ import { useState, useEffect } from 'react'

query?(params?: IQueryProps<P>['variable']): Promise<P>
onSuccess?(result: P): void
onFailure?(error: Error): void
}

@@ -56,5 +58,5 @@

const response = await mergedProps.query(variable)
try {
const response = await mergedProps.query(variable)
try {
if (response) {

@@ -67,2 +69,3 @@ setData(response)

setLoading(false)
typeof props.onSuccess === 'function' && props.onSuccess(response)

@@ -73,3 +76,5 @@ return response

return response
typeof props.onFailure === 'function' && props.onFailure(error)
return error
}

@@ -76,0 +81,0 @@ }

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