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

https://github.com/guoyunhe/lowdux

low-cost react side-load state management
https://github.com/guoyunhe/lowdux

Last synced: 4 months ago
JSON representation

low-cost react side-load state management

Awesome Lists containing this project

README

        

# lowdux

low-cost react side-load state management

## Install

```bash
npm install --save lowdux
```

## Usage

### useLowduxState()

Access a state directly

```tsx
import React from 'react';
import { useLowduxState } from 'lowdux';

function App() {
const [street, setStreet] = useLowduxState('checkout.address.street');
return (


Street:
setStreet(e.target.value)}
/>

);
}
```

### useLowduxSelector()

Remap state with selector function

```tsx
import React from 'react';
import { useLowduxSelector } from 'lowdux';

interface Product {
unitPrice: number;
quantity: number;
}

function App() {
const totalPrice = useLowduxSelector(
'checkout.products',
(products) =>
products.reduce((prev, curr) => prev + curr.unitPrice * curr.quantity, 0)
);
return

Total price: {totalPrice}
;
}
```