npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-redux-form-errors

v1.1.0

Published

A lightweight Redux Toolkit-based form error management library for React. Provides automatic error tracking, field focus management, and sequential error navigation with minimal dependencies.

Downloads

25

Readme

Here’s a README.md for your package:


📦 react-redux-form-errors

A lightweight, easy-to-use form error handling and navigation library using React and Redux Toolkit. This package helps manage form validation errors efficiently while allowing users to navigate through the errors in a sequential manner.

🚀 Features

Centralized error state management with Redux Toolkit
Automatic ref management for error fields
Smooth scrolling to each error field
Error summary display with navigation
TypeScript support
No external dependencies beyond Redux Toolkit and React


📌 Installation

Install via npm:

npm install react-redux-form-errors

or using yarn:

yarn add react-redux-form-errors

🛠 Setup

1️⃣ Add the reducer to your Redux store:

import { configureStore } from "@reduxjs/toolkit";
import { errorReducer } from "react-redux-form-errors";

export const store = configureStore({
  reducer: {
    formErrors: errorReducer,
  },
});

2️⃣ Wrap your app with Redux Provider:

import React from "react";
import { Provider } from "react-redux";
import { store } from "./store";
import App from "./App";

const Root = () => (
  <Provider store={store}>
    <App />
  </Provider>
);

export default Root;

📚 Usage

Handling Errors in Input Fields

Use the useErrorHandler hook to manage errors for individual form fields.

import React from "react";
import { useErrorHandler } from "react-redux-form-errors";

interface InputFieldProps {
  name: string;
  error?: string;
}

const InputField: React.FC<InputFieldProps> = ({ name, error }) => {
  const ref = useErrorHandler(name, !!error, error || "");

  return (
    <div>
      <input ref={ref} name={name} />
      {error && <div className="error-text">{error}</div>}
    </div>
  );
};

export default InputField;

Displaying Error Summary & Navigation

Use the useErrorNavigation hook to navigate through errors.

import React from "react";
import { useErrorNavigation } from "react-redux-form-errors";

const ErrorSummary = () => {
  const { errorCount, scrollToFirst, scrollToNext, currentErrorMessage } =
    useErrorNavigation();

  if (errorCount === 0) return null;

  return (
    <div className="error-summary">
      <p>Errors: {errorCount}</p>
      <p>Current Error Message: {currentErrorMessage}</p>
      <button onClick={scrollToFirst}>Jump to first error</button>
      <button onClick={scrollToNext}>Next error</button>
    </div>
  );
};

export default ErrorSummary;

🧪 Running Tests

This package includes tests for its hooks. To run the tests, use:

npm run test

or with yarn:

yarn test

📝 API Reference

useErrorHandler(field: string, hasError: boolean, errorMessage: string): React.RefObject<HTMLInputElement>

Handles error management for an individual form field.

| Parameter | Type | Description | | -------------- | --------- | ------------------------------ | | field | string | The name of the form field | | hasError | boolean | Whether the field has an error | | errorMessage | string | The error message to display |

Example:

const ref = useErrorHandler("email", true, "Email is required");

useErrorNavigation(): { errorCount: number, scrollToFirst: () => void, scrollToNext: () => void }

Manages error navigation within the form.

| Property | Type | Description | | --------------------- | ------------ | -------------------------------------- | | errorCount | number | The total number of errors in the form | | scrollToFirst | () => void | Scrolls to the first error field | | scrollToNext | () => void | Scrolls to the next error field | | currentErrorMessage | string | Current index error message |

Example:

const { errorCount, scrollToFirst, scrollToNext } = useErrorNavigation();

🔗 Peer Dependencies

Ensure the following peer dependencies are installed in your project:

{
  "peerDependencies": {
    "react": "^18.0.0",
    "@reduxjs/toolkit": "^2.0.0"
  }
}

📜 License

This package is licensed under the MIT License.


💡 Contributing

We welcome contributions! Feel free to submit issues or open a pull request.


📩 Support

If you have any issues or questions, feel free to open an issue on GitHub.


This README.md provides clear installation steps, usage examples, API references, and testing instructions. Let me know if you’d like any modifications! 🚀