Skip to main content

3 posts tagged with "react"

View All Tags

· 4 min read
Sivabharathy

Form validation is crucial for ensuring data integrity and a smooth user experience. In Next.js, we can validate forms using various approaches. This guide explores two methods: React Hook Form with Zod (Recommended) and Manual Validation. Both approaches include real-world examples with proper error message handling.


Why use React Hook Form?

✅ Lightweight and optimized for performance
✅ Handles form validation efficiently
✅ Easily integrates with schema validation libraries like Zod

· 7 min read
Sivabharathy

Passing data between components in React is an essential part of building applications. Depending on your app's complexity and the relationship between components, React provides multiple strategies for sharing data effectively. This article will explain the best practices for passing data in React with detailed examples and use cases.


1. Parent to Child: Using Props

The most common way to pass data in React is from a parent component to a child component using props. Props are read-only and provide a straightforward way to pass data down the component tree.

· 5 min read
Sivabharathy

What is useEffect in React?

useEffect is a React hook that allows you to perform side effects in functional components. Side effects refer to operations that interact with the outside world, such as:

  • Data fetching: Making API calls to retrieve data.
  • Subscriptions: Listening for events (e.g., from WebSockets).
  • Direct DOM manipulations: Changing the document title or manipulating third-party libraries that interact with the DOM.
  • Timers: Setting up intervals or timeouts.