Redux Tool
shadcn-customs-ui/redux-methods-toolFreeBlock
Reusable Redux Toolkit setup with store, reducers, provider, and local storage helpers.
Install it
npx shadcn@latest add https://formkitcn.pro/r/redux-methods-tool.jsonSource
1"use client";23import React, { useEffect, useState } from "react";4import { Provider } from "react-redux";5import { persistKeys, store } from "@/redux/store";6import { loadFromLocalStorage } from "@/lib/helper/storageLocal";7import type { RootState } from "@/redux/store";89// ✅ generic helper to assign values type-safely by key10function assignPersistedValue<K extends keyof RootState>(11 target: Partial<RootState>,12 key: K,13 value: RootState[K]14) {15 target[key] = value;16}1718export default function StoreProvider({19 children,20}: {21 children: React.ReactNode;22}) {23 const [ready, setReady] = useState(false);2425 useEffect(() => {26 const persisted: Partial<RootState> = {};2728 persistKeys.forEach((key) => {29 const value = loadFromLocalStorage<RootState[typeof key]>(key);30 if (value !== undefined) {31 // ✅ type-safe assignment with helper32 assignPersistedValue(persisted, key, value);33 }34 });3536 // Dispatch a rehydration event to Redux store37 store.dispatch({38 type: "__REHYDRATE__",39 payload: persisted,40 });4142 // Prevent hydration mismatch (Next.js SSR safety)43 requestAnimationFrame(() => setReady(true));44 }, []);4546 if (!ready) {47 return <div suppressHydrationWarning />;48 }4950 return <Provider store={store}>{children}</Provider>;51}
What it pulls in
npm packages
Other registry items
Files it writes
More from shadcn-customs-ui
All 8 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Data Griddata-table-dynamic | shadcn-customs-ui | Blocks | Free | 8 deps · 17 files | |
| Login Form Templateform-dynamic-template | shadcn-customs-ui | Blocks | Free | 5 deps · 7 files | |
| Field Rendererform-field | shadcn-customs-ui | Blocks | Free | 6 deps · 26 files | |
| Form Layoutform-layout | shadcn-customs-ui | Blocks | Free | no deps · 7 files | |
| Form Layout Templateform-template-01 | shadcn-customs-ui | Blocks | Free | 3 deps | |
| Step Formmultistep-form-template | shadcn-customs-ui | Blocks | Free | 6 deps · 6 files | |
| Theme Preset Tooltheme-preset-tool | shadcn-customs-ui | Blocks | Free | 1 dep · 22 files |
