React (1)
React (1)
image ta niche thake overlap kore seta ke relative diye setar position fix korte
hobe jemon right top bottom left eshb posiiton
PROPS:
Properties are the optional input that your components can accept
To generate token
**require(‘crypto’).randomBytes(64).toString(‘hex’)
Here is a list of some common HTTP status codes along with their meanings:
1xx Informational:
● 100 Continue
● 101 Switching Protocols
● 102 Processing (WebDAV)
2xx Success:
● 200 OK
● 201 Created
● 202 Accepted
● 204 No Content
● 206 Partial Content
3xx Redirection:
● 300 Multiple Choices
● 301 Moved Permanently
● 302 Found (Temporary Redirect)
● 304 Not Modified
● 307 Temporary Redirect
● 308 Permanent Redirect
4xx Client Errors:
● 400 Bad Request
● 401 Unauthorized
● 403 Forbidden
● 404 Not Found
● 405 Method Not Allowed
● 408 Request Timeout
● 409 Conflict
● 429 Too Many Requests
5xx Server Errors:
● 500 Internal Server Error
● 501 Not Implemented
● 502 Bad Gateway
● 503 Service Unavailable
● 504 Gateway Timeout
● 505 HTTP Version Not Supported
What is destructuring?
Destructuring was introduced in ES6. It’s a JavaScript feature that
One of the essential features that make ReactJS a powerful tool is the way it
handles props. Props are properties that are passed down to components,
allowing for customization and dynamic rendering of data. Destructuring of
Props is a feature in ReactJS that makes it easier to handle props in
components.
const person = {
firstName: "Lindsay",
lastName: "Criswell",
city: "NYC"
}
const { firstName, lastName, city } = person;
—-----------------
**React Hooks
import React, { useState } from 'react';
function Example() {
return (
<div>
<p>You clicked {count} times</p>
<button onClick={() => setCount(count + 1)}>
Click me
</button>
</div>
);
}
Here, useState is a Hook (we’ll talk about what this means in a moment). We call it
inside a function component to add some local state to it. React will preserve this state
between re-renders. useState returns a pair: the current state value and a function that
lets you update it. You can call this function from an event handler or somewhere else.
**USECONTEXT
https://www.freecodecamp.org/news/context-api-in-react/
Basically, Context API consists of two main components: the context provider
and the context consumer. The provider is responsible for creating and
managing the context, which holds the data to be shared between components.
On the other hand, the consumer is used to access the context and its data from
within a component.
React Router
https://www.freecodecamp.org/news/a-complete-beginners-gu
ide-to-react-router-include-router-hooks/
React-query
https://tanstack.com/query/v3/docs/framework/react/overview
React-hook -form
React Hook Form is a library for managing form state and validation in React
applications using hooks. It offers a simple and efficient way to manage form data
without the need for complex state management libraries like Redux or MobX. Here
are some key features and use cases of React Hook Form:
Simplicity: React Hook Form provides a simple and intuitive API for managing
form state. It allows you to control form inputs with minimal boilerplate code.
Performance: It optimizes performance by reducing re-renders and
unnecessary component updates. React Hook Form uses uncontrolled
components and avoids re-rendering the entire form on every keystroke.
Validation: The library offers built-in validation support, allowing you to define
validation rules for form inputs easily. It supports both synchronous and
asynchronous validation.
Customization: React Hook Form is highly customizable and allows you to
define custom validation rules, error messages, and form submission
behaviors.
Integration: It seamlessly integrates with existing React components and
libraries. You can use it with UI libraries like Material-UI or Bootstrap without
any issues.
Optimized for React: React Hook Form is optimized for use with React
functional components and hooks. It embraces the React philosophy and
leverages React's built-in features to provide a lightweight and efficient
solution for form management.
Overall, React Hook Form is a powerful tool for managing forms in React
applications, offering simplicity, performance, and flexibility for developers.
Install PropTypes: First, you need to install the prop-types package if it's not
bash
Copy code
Import PropTypes: Import PropTypes in your component file.
javascript
Copy code
Define PropTypes: Use PropTypes to define the expected types for each prop
in your component.
javascript
Copy code
MyComponent.propTypes = {
name: PropTypes.string.isRequired,
age: PropTypes.number.isRequired,
};
Example Usage:
javascript
Copy code
Greeting.propTypes = {
name: PropTypes.string.isRequired,
age: PropTypes.number.isRequired,
};
Greeting.propTypes = {
name: PropTypes.string.isRequired,
age: PropTypes.number.isRequired,
};