Here viewers, i am back again for you and now we will start coding in redux-saga. So, we will teach you make redux wrapper and code only for Store.jsx file and after that we will code in another file like Action.jsx, Reducer.jsx. So don't worry if you are confused like what i am saying now and how to manage all of things dont worry i am here for you guys. Actually we are making some project like E-commerce where we can implement searchbar, product add to cart, remove from cart, empty cart, cart section after adding some product and product section and a lot of things, So, don't worry i'm not going to leave you alone.
React
Certainly, Reactjs is a JavaScript library developed by Facenook for building user interfaces. It allows developers to create reusable UI components and effciently manage the state of their applications. Here are some key aspects of Reactjs.
Component-Based Architecture: ReactJS follows a component-based architecture, where the user interface is divided into small, reusable components. Components encapsulate their own logic, state, and rendering, making it easier to build and maintain complex user interfaces.
Virtual DOM: ReactJS uses a virtual representation of the DOM (Document Object Model), known as the Virtual DOM. When the state of a component changes, React updates the Virtual DOM.
JSX: JSX is a syntax extension for JavaScript used in React. It allows developers to write HTML-like code within JavaScript, making it easier to describe the structure and appearance of components. JSX code is transpiled to regular JavaScript using tools like Babel before being executed in the browser.
Hooks: React introduced Hooks in version 16.8 as a way to use state and other React features in functional components. Hooks allow developers to write reusable logic and manage state within functional components without the need for class components. The most commonly used hooks are useState for managing state and useEffect for handling side effects such as fetching data or subscribing to events.
React Router: React Router is a popular routing library for React applications. It enables developers to create single-page applications with multiple views and handles routing between different components based on the URL.
State Management: React provides a flexible ecosystem of state management solutions. While React's built-in state management (useState ) is suitable for managing local component state, more complex applications may benefit from additional state management libraries like Redux. These libraries help manage global application state and provide predictable ways to update and access the state.
ReactJS has gained widespread popularity due to its performance, reusability, and declarative approach to building user interfaces. It has large community.
Make Redux Wrapper
# Make all files (Action, Reducer, Store)
# Make Wrapper Around React App
# Make Redux Store
# Interview Question
Make all files (Action, Reducer, Store)
First, we make all file like action , reducer, store but only in this blog we will code inside Store,jsx file and what is the purpose of Store.jsx etc okay don't worry we will for move forward step by step.
In src folder first we make a folder as called as redux and after then we will make a file name as Action .jsx, Reducer.jsx
src folder => redux folder => Action.jsx => Reducer.jsx
If we make a reducer then for combining all reducers we make a file called as rootReducer.jsx file.
if you little bit confused don't worry gradually we will know and learn everything.
Make Wrapper Around React App
Now, inside react-app and the file is main.jsx (might be different name in your case like index.jsx) we will cover with provider around the react-app just because of if we use of redux app in another page of react app then we can access data of redux in any kind of page of react-app.
And now wrapping time. So if we remove strictmode then no issue in our
program.
import the provider from react-redux and then after removing strictmode we will write and wrap via provider.
like this -
import React from 'react' import ReactDOM from 'react-dom/client' import App from './App.jsx' import './index.css' import { Provider } from 'react-redux' //www.kumaratuljaiswal.in www.hackingtruth.in ReactDOM.createRoot(document.getElementById('root')).render( <Provider> <App /> </Provider> )
But there is some error because lets check output.
So, its time to make redux store. lets move forward with the next step.
Make Redux Store
The Redux store is the main, central bucket which stores all the states of an
application. It should be considered and maintained as a single source of
truth for the state of the application.
But you must have seen in the diagram given above, first of all we create the action file and reducer fie andonly then e create the store file, but hrer we have not yet written the code in the reducer file. so for this we create the store file. we will create a dummy store in the file.
import { createStore } from "redux"; const dummyReducer = () => { return 100 } const Store = createStore(dummyReducer) export default Store
import React from 'react' import ReactDOM from 'react-dom/client' import App from './App.jsx' import './index.css' import { Provider } from 'react-redux' import Store from './redux/Store.jsx' //www.kumaratuljaiswal.in www.hackingtruth.in console.log(Store) ReactDOM.createRoot(document.getElementById('root')).render( <Provider store={Store}> <App /> </Provider> )
Now it is finally running and all are done. After this blog we will make Action file and etc.
Watch Full Tutorial
# Install redux and saga packages - CLICK HERE
# Make reducer wrapper - CLICK HERE
# Action in reducer - CLICK HERE
# Reducer in redux - CLICK HERE
Disclaimer
All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.
0 comments:
Post a Comment
For Any Tech Updates, Hacking News, Internet, Computer, Technology and related to IT Field Articles Follow Our Blog.