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

react-use-event-hook

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-use-event-hook - npm Package Compare versions

Comparing version 0.9.1 to 0.9.2

13

dist/useEvent.js

@@ -6,2 +6,7 @@ "use strict";

/**
* Suppress the warning when using useLayoutEffect with SSR
* https://reactjs.org/link/uselayouteffect-ssr
*/
var useBrowserLayoutEffect = typeof window !== "undefined" ? react_1.useLayoutEffect : function () { };
/**
* Similar to useCallback, with a few subtle differences:

@@ -14,4 +19,4 @@ * - The returned function is a stable reference, and will always be the same between renders

// Keep track of the latest callback:
var latestRef = react_1.useRef(useEventResultShouldNotBeCalledDuringRender);
react_1.useLayoutEffect(function () {
var latestRef = react_1.useRef(useEvent_shouldNotBeInvokedBeforeMount);
useBrowserLayoutEffect(function () {
latestRef.current = callback;

@@ -33,6 +38,6 @@ }, [callback]);

*/
function useEventResultShouldNotBeCalledDuringRender() {
throw new Error("The callback from useEvent cannot be called while rendering; it should be wrapped in `useEffect` or `useLayoutEffect`.");
function useEvent_shouldNotBeInvokedBeforeMount() {
throw new Error("INVALID_USEEVENT_INVOCATION: the callback from useEvent cannot be invoked before the component has mounted.");
}
exports.default = useEvent;
//# sourceMappingURL=useEvent.js.map
{
"name": "react-use-event-hook",
"version": "0.9.1",
"version": "0.9.2",
"description": "Same as React's `useCallback`, but returns a stable reference.",

@@ -5,0 +5,0 @@ "main": "dist/useEvent.js",

@@ -6,2 +6,8 @@ import { useLayoutEffect, useRef } from "react";

/**
* Suppress the warning when using useLayoutEffect with SSR
* https://reactjs.org/link/uselayouteffect-ssr
*/
const useBrowserLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : () => {};
/**
* Similar to useCallback, with a few subtle differences:

@@ -14,4 +20,4 @@ * - The returned function is a stable reference, and will always be the same between renders

// Keep track of the latest callback:
const latestRef = useRef<TCallback>(useEventResultShouldNotBeCalledDuringRender as any);
useLayoutEffect(() => {
const latestRef = useRef<TCallback>(useEvent_shouldNotBeInvokedBeforeMount as any);
useBrowserLayoutEffect(() => {
latestRef.current = callback;

@@ -35,5 +41,5 @@ }, [callback]);

*/
function useEventResultShouldNotBeCalledDuringRender() {
function useEvent_shouldNotBeInvokedBeforeMount() {
throw new Error(
"The callback from useEvent cannot be called while rendering; it should be wrapped in `useEffect` or `useLayoutEffect`."
"INVALID_USEEVENT_INVOCATION: the callback from useEvent cannot be invoked before the component has mounted."
);

@@ -40,0 +46,0 @@ }

Sorry, the diff of this file is not supported yet

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