# @pixelherz/reactbox

> React utilities we frequently use in our projects.

Latest version **2.0.0** (published 2024-12-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install @pixelherz/reactbox
pnpm add @pixelherz/reactbox
yarn add @pixelherz/reactbox
bun add @pixelherz/reactbox
```

## Health

**Score 35/100 (D)** — status: stable.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2024-12-18 |
| First published | 2020-04-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Pixelherz GmbH |
| Maintainers | rekomat |
| Keywords | reactjs, utils, toolkit |

## Links

- npm: https://www.npmjs.com/package/@pixelherz/reactbox
- Repository: https://github.com/Pixelherz/reactbox
- Homepage: https://github.com/Pixelherz/reactbox#readme
- Issues: https://github.com/Pixelherz/reactbox/issues
- npm.io page: https://npm.io/package/@pixelherz/reactbox

## Dependencies (1)

- [prop-types](https://npm.io/package/prop-types.md) ^15.7.2

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2024-12-18
- 2.0.0-rc.2 (next) — 2024-12-10
- 2.0.0-rc.1 — 2024-12-10
- 2.0.0-rc.0 — 2024-12-10
- 1.1.4 — 2020-08-03
- 1.1.3 — 2020-04-21

## README

# reactbox
Our little [React](https://reactjs.org/) toolbox


## Install

```sh
$ npm install @pixelherz/reactbox
```


## Modules

### ScrollDistanceObserver

#### Properties

`isActive`: Boolean, de-/activates the observer. The observer is reset when re-activated (starts counting the scroll distance from zero).

`onScrollDistYUpdate`: Callback function. The current scrollY distance is passed as argument. 

```js
import { useState } from 'react'
import ScrollDistObserver from '@pixelherz/reactbox/scroll-distance-observer'

export default const MyComp = ({}) => {
  const [ isObserverActive, setIsObserverActive ] = useState(true)
  return (
    <ScrollDistObserver
      isActive={isObserverActive}
      onScrollDistYUpdate={scrollDistY => {
        console.log(`scrollY distance is ${scrollDistY}px`)
        if (scrollDistY >= 500) {
          setIsObserverActive(false)
        }
      }}
    />
  )
}
```

### ScrollOffsetObserver

#### Properties

`isActive`: Boolean, de-/activates the observer. 

`onScrollOffsetYUpdate`: Callback function. The current scrollY offset is passed as argument. 

```js
import ScrollOffsetObserver from '@pixelherz/reactbox/scroll-offset-observer'

export default const MyComp = ({}) => {
  const [ isObserverActive, setIsObserverActive ] = useState(true)
  return (
    <ScrollOffsetObserver
      isActive
      onScrollOffsetYUpdate={scrollOffsetY => {
        console.log(`scrollY offset is ${scrollOffsetY}px`)
      }}
    />
  )
}
```


## Development

### Build

```sh
$ npm run build
```

### Publish

```sh
$ npm publish
```

### Versioning

We use [Semantic Versioning](https://semver.org/).


## Contact

Pixelherz  
Design und Code für Digitales

René Keller  
rene@pixelherz.com

Pixelherz GmbH  
Allmendstrasse 61  
CH-8041 Zürich

[pixelherz.com](https://pixelherz.com)

---
_Source: https://npm.io/package/@pixelherz/reactbox · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
