@codebayu/use-hydration-zustand
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

@codebayu/use-hydration-zustand

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

Installation

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

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

Usage

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 (
    <div>
      {isHydrated ? (
        items.map((item) => <Card {...item} key={item.id} />)
      ) : (
        <Loading />
      )}
    </div>
  );
}

export default MyComponent;

API

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

Parameters

  • store (UseBoundStore<any>): The Zustand store.

Returns

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

License

This project is licensed under the MIT License - see the LICENSE file for details.

Package Sidebar

Install

npm i @codebayu/use-hydration-zustand

Weekly Downloads

13

Version

1.0.4

License

MIT

Unpacked Size

5.51 kB

Total Files

9

Last publish

Collaborators

  • bayu-setiawan