Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/marcolink/react-sink

A classy kitchen sink for all react pieces daily used - not the ordinary.
https://github.com/marcolink/react-sink

Last synced: 2 months ago
JSON representation

A classy kitchen sink for all react pieces daily used - not the ordinary.

Awesome Lists containing this project

README

        

# react sink
A classy kitchen sink for all react pieces daily used - not the ordinary.

[![Version](https://img.shields.io/npm/v/react-sink.svg)](https://npmjs.org/package/react-sink)
[![Downloads/week](https://img.shields.io/npm/dw/react-sink.svg)](https://npmjs.org/package/react-sink)
[![Size](https://img.shields.io/bundlephobia/min/react-sink.svg)](https://npmjs.org/package/react-sink)
[![Semantic Release](https://github.com/marcolink/react-sink/actions/workflows/semantic-release.yml/badge.svg)](https://github.com/marcolink/react-sink/actions/workflows/semantic-release.yml)

### Install
**yarn**
```
yarn add react-sink
```
**npm**
```
npm i react-sink
```

## Components

### ``
```typescript jsx
import { Conditional } from 'react-sink'

function MyComponent({ isLoading, isError }) {
return (

rendered when complete

)
}
```

### ``
```typescript jsx
import { Conditional } from 'react-sink'

function MyComponent({ flag }) {
return (

rendered when true

)
}
```

### ``
```typescript jsx
import {ConditionalWrapper} from 'react-sink'

function MyComponent({flag}) {
return (

{children}

}>
rendered for truthy condition

)
}
```

## Hooks
### `useAllBoolean`
```typescript jsx
import { useAllBoolean } from 'react-sink'

function MyComponent() {
const expectAllTrueWillBeFalse = useAllBoolean({ hello: true, world: false })
const expectAllTrueWillBeTrue = useAllBoolean({ hello: true, world: true })
const expectAllFalseWillBeFalse = useAllBoolean({ hello: false, world: false }, false)
}
```

### `usePeriodicCallback`

```typescript jsx
import {useCallback} from "react";
import {usePeriodicCallback} from 'react-sink'

function MyComponent() {
const callback = useCallback(()=> console.log("called!"), [])
const result = usePeriodicCallback(callback, 100)
}
```

### `useWindowSize`

```typescript jsx
import {useWindowSize} from 'react-sink'

function MyComponent() {
const { width, height } = useWindowSize()
}
```

### `useAbortOnUnmount`

```typescript jsx
import {useAbortOnUnmount} from 'react-sink'

function MyComponent() {
const abortSignal = useAbortOnUnmount()
}
```