Skip to main content

Posts

ReactJS(v18) | Redux Toolkit | State Management | CRUD Example

In this article, we will implement ReactJS application state management using Redux Toolkit with a CRUD example. Redux Toolkit For State Management: In the ReactJS application to share data between components consistently, we can use the Redux Toolkit.  The Redux Toolkit is built on top of the standard 'Redux' to overcome a few concerns like 'complexity to configure the redux', 'avoiding additional packages to integrate with redux', 'to avoid the too much boilerplate code generated by redux'. The main building component of Redux Toolkit are: Actions - actions represent events to trigger the reducer to update data into the store. Reducers - In general in 'Redux' reducer pure function to create the state instead of changing the state. But in 'Redux Toolkit' we can mutate the state directly, but internally using the 'Immer' library our logic generates a new state instead of mutating the existing state. Store - object where we store o

ReactJS(v18) Form Validation | React Hook Form(v7) | React Bootstrap UI Form Components

In this article, we will understand the ReactJS form validation for React Bootstrap UI form components using the Rect Hook Form library. Create ReactJS Application: Let's create a simple ReactJS application to accomplish our demo. npx create-react-app name-of-your-app Install React Bootstrap Library: Let's install React Bootstrap UI library. npm install react-bootstrap bootstrap Import the bootstrap CSS file reference onto the  'index.js' file src/index.js: import 'bootstrap/dist/css/bootstrap.min.css'; Install React Hook From Library: Install the React Hook Form Library. npm install react-hook-form A Simple React Bootstrap Form Using React Hook Form Library: Let's create a simple Rect bootstrap Form and integrate the React Hook Form library to read the form data. src/App.js: import "./App.css"; import Row from "react-bootstrap/Row"; import Button from "react-bootstrap/Button"; import Col from "react-bootstrap/Col

ReactJS(v18) Form Validations | React Hook Form Library | Bootstrap

In this article, we are going to understand the form validation in the ReactJS application using the 'React Hook Form' library and bootstrap for UI design. Create ReactJS Application: Let's create the ReactJS application to accomplish our demo. npx create-react-app name-of-your-app Now install the bootstrap into our application. npm install bootstrap@5.2.1 Now import the bootstrap CSS file onto the 'index.js'. src/index.js: import 'bootstrap/dist/css/bootstrap.min.css' Install React Hook Form Library: Let's install the 'React Hook Form' library. npm install react-hook-form A Simple Form Using React Hook From Library: Let's implement a simple form in our 'App' component. src/App.js: import logo from "./logo.svg"; import "./App.css"; import { useForm } from "react-hook-form"; function App() { const { register, handleSubmit, formState: { errors }, } = useForm(); const onformS