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

use-state-with-callback

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-state-with-callback - npm Package Compare versions

Comparing version 2.0.3 to 2.0.5

.nyc_output/93918fce-dec8-48ea-a76b-0bbcaf6021f0.json

2

.nyc_output/processinfo/index.json

@@ -1,1 +0,1 @@

{"processes":{"9a889e5a-e32a-4e37-9057-00df28a0f0af":{"parent":null,"children":["f87f99cb-1220-4a09-b453-b6f80a360070"]},"f87f99cb-1220-4a09-b453-b6f80a360070":{"parent":"9a889e5a-e32a-4e37-9057-00df28a0f0af","children":[]}},"files":{"/Users/mydspr/Developer/Repos/use-state-with-callback/src/spec.js":["f87f99cb-1220-4a09-b453-b6f80a360070"],"/Users/mydspr/Developer/Repos/use-state-with-callback/src/index.js":["f87f99cb-1220-4a09-b453-b6f80a360070"]},"externalIds":{}}
{"processes":{"93918fce-dec8-48ea-a76b-0bbcaf6021f0":{"parent":null,"children":[]}},"files":{},"externalIds":{}}

@@ -1,16 +0,24 @@

import React, {SetStateAction, Dispatch} from 'react';
import { SetStateAction, Dispatch } from 'react';
type DispatchWithCallback<A> = (value: A, callback: Callback) => void;
type DispatchWithCallback<A, S> = (
value: A,
callback: Callback<S>,
) => void;
type Callback<S> = (state:s) => (void | (() => void | undefined));
type Callback<S> = (state: S) => void | (() => void | undefined);
declare function useStateWithCallback<S>(
initialState: S,
callback: Callback<S>,
): [S, Dispatch<SetStateAction<S>>];
declare function useStateWithCallback<S>(initialState:S,callback:Callback) : [S,Dispatch<SetStateAction<S>>];
export declare function useStateWithCallbackInstant<S>(
initialState: S,
callback: Callback<S>,
): [S, Dispatch<SetStateAction<S>>];
export declare function useStateWithCallbackInstant<S>(initialState:S,callback:Callback) : [S,Dispatch<SetStateAction<S>>];
export declare function useStateWithCallbackLazy<S>(
initialState: S,
): [S, DispatchWithCallback<SetStateAction<S>, S>];
export declare function useStateWithCallbackLazy<S>(initialState:S) : [S,DispatchWithCallback<SetStateAction<S>>];
export default useStateWithCallback;
export default useStateWithCallback;

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports["use-state-with-callback"]=e(require("react")):t["use-state-with-callback"]=e(t.react)}(window,function(t){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var u=e[n]={i:n,l:!1,exports:{}};return t[n].call(u.exports,u,u.exports,r),u.l=!0,u.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var u in t)r.d(n,u,function(e){return t[e]}.bind(null,u));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=1)}([function(e,r){e.exports=t},function(t,e,r){"use strict";r.r(e),r.d(e,"useStateWithCallbackInstant",function(){return o}),r.d(e,"useStateWithCallbackLazy",function(){return c});var n=r(0);function u(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=[],n=!0,u=!1,o=void 0;try{for(var c,i=t[Symbol.iterator]();!(n=(c=i.next()).done)&&(r.push(c.value),!e||r.length!==e);n=!0);}catch(t){u=!0,o=t}finally{try{n||null==i.return||i.return()}finally{if(u)throw o}}return r}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var o=function(t,e){var r=u(Object(n.useState)(t),2),o=r[0],c=r[1];return Object(n.useLayoutEffect)(function(){return e(o)},[o,e]),[o,c]},c=function(t){var e=Object(n.useRef)(null),r=u(Object(n.useState)(t),2),o=r[0],c=r[1];Object(n.useEffect)(function(){e.current&&(e.current(o),e.current=null)},[o]);return[o,function(t,r){return e.current=r,c(t)}]};e.default=function(t,e){var r=u(Object(n.useState)(t),2),o=r[0],c=r[1];return Object(n.useEffect)(function(){return e(o)},[o,e]),[o,c]}}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports["use-state-with-callback"]=e(require("react")):t["use-state-with-callback"]=e(t.react)}(window,function(t){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var u=e[n]={i:n,l:!1,exports:{}};return t[n].call(u.exports,u,u.exports,r),u.l=!0,u.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var u in t)r.d(n,u,function(e){return t[e]}.bind(null,u));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=1)}([function(e,r){e.exports=t},function(t,e,r){"use strict";r.r(e),r.d(e,"useStateWithCallbackInstant",function(){return o}),r.d(e,"useStateWithCallbackLazy",function(){return c});var n=r(0);function u(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=[],n=!0,u=!1,o=void 0;try{for(var c,i=t[Symbol.iterator]();!(n=(c=i.next()).done)&&(r.push(c.value),!e||r.length!==e);n=!0);}catch(t){u=!0,o=t}finally{try{n||null==i.return||i.return()}finally{if(u)throw o}}return r}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var o=function(t,e){var r=u(n.useState(t),2),o=r[0],c=r[1];return n.useLayoutEffect(function(){return e(o)},[o,e]),[o,c]},c=function(t){var e=n.useRef(null),r=u(n.useState(t),2),o=r[0],c=r[1];n.useEffect(function(){e.current&&(e.current(o),e.current=null)},[o]);return[o,function(t,r){return e.current=r,c(t)}]};e.default=function(t,e){var r=u(n.useState(t),2),o=r[0],c=r[1];return n.useEffect(function(){return e(o)},[o,e]),[o,c]}}])});
{
"name": "use-state-with-callback",
"version": "2.0.3",
"version": "2.0.5",
"description": "",

@@ -8,5 +8,3 @@ "main": "lib/index.js",

"build": "webpack --config ./webpack.config.js --mode=production",
"prepare": "npm run build",
"test": "nyc mocha --require @babel/register --require ./test/dom.js 'src/**/**spec.js'",
"coverage": "nyc report --reporter=text-lcov | coveralls"
"prepare": "npm run build"
},

@@ -17,4 +15,4 @@ "keywords": [],

"peerDependencies": {
"react": "^16.8.6",
"react-dom": "^16.8.6"
"react": ">=16.8.0",
"react-dom": ">=16.8.0"
},

@@ -30,7 +28,3 @@ "devDependencies": {

"babel-loader": "^8.0.5",
"chai": "^4.2.0",
"copy-webpack-plugin": "^5.1.1",
"coveralls": "^3.0.3",
"enzyme": "^3.9.0",
"enzyme-adapter-react-16": "^1.13.2",
"eslint": "^5.16.0",

@@ -45,9 +39,5 @@ "eslint-config-airbnb": "^18.0.0",

"eslint-plugin-react-hooks": "^1.6.1",
"jsdom": "^15.1.1",
"mocha": "^6.1.4",
"nyc": "^14.1.1",
"prettier": "^1.18.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"sinon": "^7.3.2",
"webpack": "^4.31.0",

@@ -54,0 +44,0 @@ "webpack-cli": "^3.3.2"

# useStateWithCallback React Hook
[![Build Status](https://travis-ci.org/the-road-to-learn-react/use-state-with-callback.svg?branch=master)](https://travis-ci.org/the-road-to-learn-react/use-state-with-callback) [![Slack](https://slack-the-road-to-learn-react.wieruch.com/badge.svg)](https://slack-the-road-to-learn-react.wieruch.com/) [![Greenkeeper badge](https://badges.greenkeeper.io/the-road-to-learn-react/use-state-with-callback.svg)](https://greenkeeper.io/) [![Coverage Status](https://coveralls.io/repos/github/the-road-to-learn-react/use-state-with-callback/badge.svg?branch=master)](https://coveralls.io/github/the-road-to-learn-react/use-state-with-callback?branch=master) ![NPM](https://img.shields.io/npm/l/use-state-with-callback.svg)
[![Build Status](https://travis-ci.org/the-road-to-learn-react/use-state-with-callback.svg?branch=master)](https://travis-ci.org/the-road-to-learn-react/use-state-with-callback) [![Slack](https://slack-the-road-to-learn-react.wieruch.com/badge.svg)](https://slack-the-road-to-learn-react.wieruch.com/) [![Greenkeeper badge](https://badges.greenkeeper.io/the-road-to-learn-react/use-state-with-callback.svg)](https://greenkeeper.io/) ![NPM](https://img.shields.io/npm/l/use-state-with-callback.svg)

@@ -15,3 +15,3 @@ Custom hook to include a callback function for useState which was previously available for setState in class components. [Read more about it here.](https://www.robinwieruch.de/react-usestate-callback/)

```
```jsx
import React from 'react';

@@ -56,3 +56,3 @@

```
```jsx
import React from 'react';

@@ -59,0 +59,0 @@ import { useStateWithCallbackLazy } from 'use-state-with-callback';

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