npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@springtree/eva-suite-react-hooks

v1.29.0

Published

Shared React custom hooks library for the EVA Admin suite modules

Downloads

39

Readme

EVA Suite React Hooks

This package contains custom React hooks that we use in multiple EVA Suite modules.

Install into you React package

npm i @springtree/eva-suite-react-hooks

Usage

You can use the package like this.

import React from 'react';
import { useDebounce } from '@springtree/eva-suite-react-hooks';

const Example: React.FC = () => {
  const [inputValue, setInputValue] = React.useState<string | undefined>();
  const debouncedInputValue = useDebounce(inputValue, 500);

  return (
    <>
      <input
        type="text"
        value={inputValue ?? ''}
        onChange={(event) => setInputValue(event.target.value)}
      >
      <span>
        {`The debounced value is: ${debouncedValue}`}
      </span>
    </>
  )
}

These are the current hooks:

  • useActionOnUnmount => With this hook you can kick of an action with data before the component unmounts
  • useBoolean => Handy custom hook which gives you callbacks to either update or toggle a boolean state value
  • useDebounce => Debounce any state value with this hook.
  • useEnumToArray => Convert enum to an array.
  • useEventListener => If you find yourself adding a lot of event listeners using useEffect you might consider using this hook.
  • useHandleSWR => Make sure data gets refreshed when you return to it.
  • useHandleSWRFamily => Make sure data gets refreshed when you return to it.
  • useHasFunctionality => returns if the user may or may not use an EVA functionality.
  • useHasFunctionalityWithoutScope => returns if the user may or may not use an unscoped EVA functionality.
  • useAllowedFunctionality => check if current user has access to certain functionalities (based on useHasFunctionality and useHasFunctionalityWithoutScope hooks)
  • useLocalStorage => Custom hook that works just like useState, but based on localStorage.
  • useParseStringToFloat => Parses a string value to a float or undefined.
  • useParseStringToInteger => Parses a string valeu to a integer or undefined.
  • usePrevious => Get the previous value of a state value.
  • useSentry => setup sentry in EVA app
  • useUndo => Custom hook for managing undo / redo on state values.
  • useWhyDidYouUpdate => This hook makes it easy to see which prop changes are causing a component to re-render.
  • useBoundingRectangle => This hook saves and returns the last known bounding box (position and dimensions) of a DOM element. It also updates on resize events.
  • useNavigateToChildPath => navigate to a URL, that has the same prefix as the current URL (e.g. /api/users -> /api/users/3).
  • useRecoilDebouncedValue => Debounce Recoil state setter.
  • useHotjar => Initialize Hotjar for the application based on eva-config.
  • useHandle404 => Redirects the user to a 404 page on EntityNotFound errors
  • useParsedRouteParam => Gets route params as integer values
  • useServiceError => Gets service errors
  • useCallService => Helper hook to call a service
  • useInterval => Execute callback on interval
  • useAppSetting => Get the value of a setting
  • useProductIDProperty => Get the configured product id property from app setting
  • useProductImageById => Get the url for the primary image of a product based on the EVA ID of the product when you don't have the blob id available

Testing

We try to write tests for every new hook. You can use react-hooks-testing-library to see how you should write your tests. Jest is the testing framework.