Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/codebayu/use-hydration-zustand

React hook for handle the persist state of zustand
https://github.com/codebayu/use-hydration-zustand

hydration zustand zustand-persist

Last synced: 22 days ago
JSON representation

React hook for handle the persist state of zustand

Awesome Lists containing this project

README

        

# @codebayu/use-hydration-zustand

A React Custom Hook for Zustand state management library to simplify hydration handling.

## Installation

```bash
# npm
npm install @codebayu/use-hydration-zustand

# yarn
yarn add @codebayu/use-hydration-zustand
```

## Usage

```tsx
import { useHydrationZustand } from '@codebayu/use-hydration-zustand';
import create from 'zustand';

// Your Zustand store
const useStore = create((set) => ({
// Your store definition here
}));

function MyComponent() {
// Use the useHydrationZustand hook
const isHydrated = useHydrationZustand(useStore);

return (


{isHydrated ? (
items.map((item) => )
) : (

)}

);
}

export default MyComponent;
```

## API

`useHydrationZustand(store)`
A hook for Zustand that simplifies hydration handling.

Parameters

- `store (UseBoundStore)`: The Zustand store.

Returns

- `boolean`: true if the store has finished hydration, false otherwise.

## License

This project is licensed under the [MIT License](https://opensource.org/licenses/MIT) - see the [LICENSE](LICENSE) file for details.