Socket
Book a DemoInstallSign in
Socket

@stefanoruth/react-helpers

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stefanoruth/react-helpers

A small set of components to help bulding simpler code.

latest
Source
npmnpm
Version
1.0.27
Version published
Maintainers
1
Created
Source

React Helpers

A small set of components to help bulding simpler code.

version license size

Features

  • Scroll lock
  • Focus trap
  • Click away listener
  • Keyboard listiner
  • Simple Portals
  • ClassName builder
  • Config Builder
  • Interval Hook

Installation

yarn add @stefanoruth/react-helpers

or

npm install @stefanoruth/react-helpers --save

Basic usage

import { Portal, useScrollLockEffect, useTabFocus, useOnClickAway, useOnEscKey } from '@stefanoruth/react-helpers'

export const Modal: React.FunctionComponent<{ onClose: () => void }> = props => {
    const modalRef = React.useRef < HTMLDivElement > null

    useScrollLockEffect()

    useTabFocus(modalRef)

    useOnClickAway(modalRef, () => {
        props.onClose()
    })

    useOnEscKey(() => {
        props.onClose()
    })

    return (
        <Portal>
            <div ref={modalRef}>
                <button onClick={props.onClose}>Close</button>
                {props.children}
            </div>
        </Portal>
    )
}

Development

https://reactjs.org/warnings/invalid-hook-call-warning.html#duplicate-react

npm link example/node_modules/react

yarn dev

License

MIT

FAQs

Package last updated on 09 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.