<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Daniel Onugha</title>
    <description>The latest articles on DEV Community by Daniel Onugha (@danielonugha0).</description>
    <link>https://dev.to/danielonugha0</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F932045%2F792f8b88-8624-4d0c-b1f9-33f3e97ebcc8.jpg</url>
      <title>DEV Community: Daniel Onugha</title>
      <link>https://dev.to/danielonugha0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/danielonugha0"/>
    <language>en</language>
    <item>
      <title>React Management hook Vs Redux</title>
      <dc:creator>Daniel Onugha</dc:creator>
      <pubDate>Wed, 29 Mar 2023 15:40:20 +0000</pubDate>
      <link>https://dev.to/danielonugha0/react-management-hook-vs-redux-3c32</link>
      <guid>https://dev.to/danielonugha0/react-management-hook-vs-redux-3c32</guid>
      <description>&lt;p&gt;In building applications, managing data is essential, redux and react hooks are different things with different distant goals. It is said that react state management is one of the hardest problems developers encounter while trying to create react app.&lt;/p&gt;

&lt;p&gt;What is react management hook?&lt;br&gt;
React management hooks are a feature in React that allow you to manage state and side effects in functional components. They were introduced in React 16.8 and are a more modern way of handling state and side effects compared to class components.&lt;/p&gt;

&lt;p&gt;What is redux&lt;br&gt;
Redux is a state management library that can be used with React (and other frameworks). It provides a centralized store for all the states in your application and uses actions and reducers to manage updates to the store. Unlike React hooks, Redux is not a part of React and requires additional setup and configuration to use.&lt;/p&gt;

&lt;p&gt;Principles of redux&lt;br&gt;
Redux is a state management library for JavaScript applications that follows a set of principles to make it easy to manage and update the state of an application predictably. These principles are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Actions: In Redux, an action is a plain JavaScript object that represents an intention to change the state in a Redux application. An action object must have a &lt;code&gt;type&lt;/code&gt;property, which is a string that describes the type of action that is being performed, and a &lt;code&gt;payload&lt;/code&gt;object contains the information that should be used to change the state. Actions may also include other properties that provide additional information about the change that should be made to the state.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// action.js
const reduxAction = payload =&amp;gt; {
  return {
    type: 'action description',
    payload
  }
};

export default reduxAction;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The &lt;code&gt;text&lt;/code&gt;property provides the text of the new to-do item. Actions are dispatched using the &lt;code&gt;store.dispatch()&lt;/code&gt; method. The dispatch action is then passed through the reducer functions, which update the state of the application based on the type of action.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reducers: A reducer function in Redux is responsible for modifying the state of the application in response to actions dispatched to the store.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
const reducer = (state, action) =&amp;gt; {
  const { type, payload } = action;
  switch(type){
    case "action type":
      return {
        ["action description"]: payload
      };
    default:
      return state;
  }
};

export default reducer;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Store: The Redux store is a centralized container for the state of a JavaScript application using the Redux library. It holds the current state of the application and provides a way to access and update the state through dispatching actions. The store is created using the create store()method from the Redux library and it must be the single source of truth for the entire application. Redux bears only one store in any redux application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
import { createStore } from 'redux'

const store = createStore(componentName);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The store also allows for adding middleware, which allows for modifying the dispatch actions before they reach the reducer, and for adding subscribers, which receive notifications whenever the state changes.&lt;/p&gt;

&lt;p&gt;What are React Hooks?&lt;br&gt;
React Hooks are a feature in react that allows you to add state and other React features to useful components. Before the introduction of hooks, state, and other React features could only be used with class components.&lt;br&gt;
Hooks are a way to reuse stateful logic, not just state, between components. There are several built-in hooks such as &lt;code&gt;useState&lt;/code&gt;, &lt;code&gt;useEffect&lt;/code&gt;, and &lt;code&gt;useContext&lt;/code&gt;, but you can also create your hooks.&lt;br&gt;
Hooks provide a way to add state, side effects, and other React features to functional components in a way that's easier to understand and use. Some of the most commonly used hooks include &lt;code&gt;useState&lt;/code&gt;which allows you to add state to useful components and &lt;code&gt;useEffect&lt;/code&gt;which lets you perform side effects in response to component updates.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The useReducer Hook:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code&gt;useReducer&lt;/code&gt;hook is a hook in React that allows you to manage the state of your component using a reducer function. A reducer is a pure function that takes the current state and an action as arguments and returns a new state.&lt;br&gt;
The &lt;code&gt;useReducer&lt;/code&gt;hook provides a way to manage a state that is more complex than what can be achieved with the &lt;code&gt;useState.&lt;/code&gt; It is especially useful when you have state updates that are related to one another, and you want to manage those updates in a single, centralized location.&lt;br&gt;
The &lt;code&gt;useReducer&lt;/code&gt;hook takes two arguments: the first argument is a reducer function, and the second argument is the initial state. It returns an array containing the current state and a dispatch function, which is used to dispatch actions to the reducer.&lt;br&gt;
Here's a simple example of how you can use the &lt;code&gt;useReducer&lt;/code&gt; hook:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
import React, { useReducer } from 'react';

const initialState = { count: 0 };

function reducer(state, action) {
  switch (action.type) {
    case 'increment':
      return { count: state.count + 1 };
    case 'decrement':
      return { count: state.count - 1 };
    default:
      throw new Error();
  }
}

function Counter() {
  const [state, dispatch] = useReducer(reducer, initialState);

  return (
    &amp;lt;&amp;gt;
      Count: {state.count}
      &amp;lt;button onClick={() =&amp;gt; dispatch({ type: 'increment' })}&amp;gt;+&amp;lt;/button&amp;gt;
      &amp;lt;button onClick={() =&amp;gt; dispatch({ type: 'decrement' })}&amp;gt;-&amp;lt;/button&amp;gt;
    &amp;lt;/&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The useContext Hook:&lt;br&gt;
The &lt;code&gt;useContext&lt;/code&gt;hook in React allows you to access data from a context object in a functional component. The context system in React provides a way to share data across multiple components in your application, without having to pass the data down through props.&lt;br&gt;
Here's a simple example of how to use the &lt;code&gt;useContext&lt;/code&gt;hook:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
//javascript
import React, { createContext, useContext } from 'react';

const UserContext = createContext({ name: 'Guest' });

function UserDisplay() {
  const user = useContext(UserContext);
  return &amp;lt;div&amp;gt;{`Hello, ${user.name}`}&amp;lt;/div&amp;gt;;
}

function App() {
  return (
    &amp;lt;UserContext.Provider value={{ name: 'MUO' }}&amp;gt;
      &amp;lt;UserDisplay /&amp;gt;
    &amp;lt;/UserContext.Provider&amp;gt;
  );
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we create a context object with &lt;code&gt;createContext&lt;/code&gt;and pass a default value of &lt;code&gt;{ name: 'Guest' }&lt;/code&gt;. Then, we use the &lt;code&gt;useContext&lt;/code&gt;hook in the &lt;code&gt;UserDisplay&lt;/code&gt;component to access the data from the context object. The &lt;code&gt;UserDisplay&lt;/code&gt;component will display "Hello, ChatGPT".&lt;br&gt;
Finally, we wrap the &lt;code&gt;UserDisplay&lt;/code&gt;component with the &lt;code&gt;UserContext.Provider&lt;/code&gt;component and pass a value of &lt;code&gt;{ name: 'MUO' }&lt;/code&gt; to it. This makes the data from the context object available to all components inside the provider.&lt;/p&gt;

&lt;p&gt;React Hooks vs Redux State Management.&lt;br&gt;
React Hooks and Redux State Management are two approaches for managing the state in a React application.&lt;/p&gt;

&lt;p&gt;React Hooks are a new way to manage states within a React component. They allow developers to manage state and side effects within the component itself, without the need for a separate state management library. React Hooks are easier to understand and use compared to traditional React state management, making them a good choice for smaller and simpler applications.&lt;/p&gt;

&lt;p&gt;Redux State Management is a state management library that helps manage the global states within a React application. It provides a centralized store for data, which makes it easier to share data between components. Redux also provides a robust set of tools for debugging and testing the application, making it a good choice for larger and more complex applications.&lt;/p&gt;

&lt;p&gt;Ultimately, the choice between React Hooks and Redux State Management depends on the size and complexity of the application. React Hooks are a good choice for simple and small applications, while Redux State Management is a better choice for larger and more complex applications.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;br&gt;
Both React Hooks and Redux State Management have their advantages and disadvantages as we explored in the article. React Hooks provide a simpler and more intuitive way of managing state within a component, while Redux State Management provides a centralized way of managing state across the entire application using the &lt;code&gt;useContex&lt;/code&gt;and &lt;code&gt;useReducer&lt;/code&gt;hooks. Choosing between the two is a matter of preference or choice.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>redux</category>
      <category>react</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Rust and Scala: Comparisons</title>
      <dc:creator>Daniel Onugha</dc:creator>
      <pubDate>Mon, 27 Mar 2023 13:38:48 +0000</pubDate>
      <link>https://dev.to/danielonugha0/rust-and-scala-comparisons-3nda</link>
      <guid>https://dev.to/danielonugha0/rust-and-scala-comparisons-3nda</guid>
      <description>&lt;p&gt;Rust and Scala belong to the "Languages" category of the tech stack, they are both open-source tool, which is mostly used in most cases, the application grows, has scalability, and has a unique application function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is rust?&lt;/strong&gt;&lt;br&gt;
Rust is a systems programming language developed by Mozilla Research. It was created to provide a safe and concurrent alternative to lower-level languages such as C and C++. Rust also has a modern syntax and type system, making it easier to write clean and maintainable code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2j0l3apd4uspt0yabx42.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2j0l3apd4uspt0yabx42.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
[why choosing rust]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Features of a simple Rust Program&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Main function: The main function acts as the starting point of the program and is executed first when the program is run.&lt;/li&gt;
&lt;li&gt;Variables: Variables are used to store values and can be declared using the let keyword.&lt;/li&gt;
&lt;li&gt;Data Types: Rust supports various data types including integers, floating-point numbers, strings, and booleans&lt;/li&gt;
&lt;li&gt;Ownership: Rust implements an ownership system that ensures memory safety and prevents data from being accidentally overwritten or deleted.&lt;/li&gt;
&lt;li&gt;Cargo: Rust provides a package manager called Cargo that allows developers to manage dependencies and build their programs easily.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Anatomy of simple rust program&lt;/strong&gt;&lt;br&gt;
A simple Rust program consists of the following components:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Main function: This is the entry point of the program and is defined with the &lt;code&gt;fn main()&lt;/code&gt; syntax.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here’s a minimal “Hello, there!” program in Rust:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
    fn main() {&lt;br&gt;
        println!(“Hello, there!”);&lt;br&gt;
    }&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Modules: Modules are used to organize code into reusable and organized chunks.&lt;/li&gt;
&lt;li&gt;Variables and Constants: Variables store values that can be changed, whereas constants are fixed values that cannot be changed.&lt;/li&gt;
&lt;li&gt;Functions: Functions allow you to summarize and reuse logic in your program.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Cases where Rust is popularly used&lt;/strong&gt;&lt;br&gt;
Rust is a systems programming language and is used in a variety of applications where performance, reliability, and stability are crucial. Some popular use cases of Rust include:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropboxusercontent.com%2Fs_BA80BF571C2AF8B1F6C447A627BD26456FA93255A6F169FA0E3761B339EBFF3D_1675857833554_2023-02-08%2B3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropboxusercontent.com%2Fs_BA80BF571C2AF8B1F6C447A627BD26456FA93255A6F169FA0E3761B339EBFF3D_1675857833554_2023-02-08%2B3.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Systems programming: Rust is designed for systems programming and is used to build operating systems, device drivers, and game engines.&lt;/li&gt;
&lt;li&gt;Web development: Rust has a growing ecosystem for web development and is used to build high-performance web applications and APIs.&lt;/li&gt;
&lt;li&gt;Networking: Rust's low-level control and high-level abstractions make it a popular choice for networking applications and protocols.&lt;/li&gt;
&lt;li&gt;Game development: Rust's performance and safety features make it a suitable choice for game development, both for game engines and game logic.&lt;/li&gt;
&lt;li&gt;Blockchain: Rust is used to build blockchain infrastructure and decentralized applications, due to its memory-safe and concurrent design.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;What is Scala?&lt;/strong&gt;&lt;br&gt;
Scala is a programming language that operates on the Java Virtual Machine and provides support for functional programming in addition to object-oriented programming. It was created to address some of the limitations of Java and provide a more concise, scalable, and expressive language for developers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Features of Scala&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Object-Oriented: Scala supports object-oriented programming, which makes it easy to work with objects, classes, and inheritance.&lt;/li&gt;
&lt;li&gt;Concurrent: Scala supports concurrent programming and has features that make it easy to write multi-threaded applications.&lt;/li&gt;
&lt;li&gt;Interoperability: Scala is fully interoperable with Java and can access Java libraries and classes seamlessly.&lt;/li&gt;
&lt;li&gt;Syntax: Scala has a concise and expressive syntax that makes it easier to write complex applications.&lt;/li&gt;
&lt;li&gt;Traits: Scala has a concept of traits, which is a way to share common behavior among classes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Anatomy of a simple Scala program&lt;/strong&gt;&lt;br&gt;
Here is an anatomy of a simple Scala program:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Loops: Loops, such as for and while can be used to repeat a block of code.&lt;/li&gt;
&lt;li&gt;Expressions: Expressions in Scala can be simple calculations or complex operations.&lt;/li&gt;
&lt;li&gt;Return statement: The return statement is used to return a value from a function.&lt;/li&gt;
&lt;li&gt;Exception handling: Exception handling is used to handle errors and exceptions in the program.&lt;/li&gt;
&lt;li&gt;Closing bracket: The closing bracket of the object marks the end of the program.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Example of a simple Scala program:&lt;/strong&gt;&lt;br&gt;
Every Scala program should start with the &lt;code&gt;main&lt;/code&gt;method as seen in the code block below, the object, and an expression.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;object makeuseof {&lt;br&gt;
      def main(args: Array[String]) {&lt;br&gt;
        println(“Hello there!”)&lt;br&gt;
      }&lt;br&gt;
    }&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;println&lt;/code&gt;method prints the data argument in a new line.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Popular Scala use cases&lt;/strong&gt;&lt;br&gt;
Scala is a popular programming language that is used for a variety of purposes, including:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropboxusercontent.com%2Fs_BA80BF571C2AF8B1F6C447A627BD26456FA93255A6F169FA0E3761B339EBFF3D_1675861280696_2023-02-08%2B6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropboxusercontent.com%2Fs_BA80BF571C2AF8B1F6C447A627BD26456FA93255A6F169FA0E3761B339EBFF3D_1675861280696_2023-02-08%2B6.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Web development: Scala is often used for building high-performance, scalable web applications, particularly when using the Play framework.&lt;/li&gt;
&lt;li&gt;Big Data Processing: Scala is used in processing large datasets with tools like Apache Spark and Apache Kafka.&lt;/li&gt;
&lt;li&gt;Machine learning: Scala is used in the development of machine learning algorithms, particularly when using the Apache Spark MLlib library.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These are the basic building blocks of a Rust program. To create more complex applications, you can also make use of features like crates, enums, traits, and more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Comparing Scala and Rust&lt;/strong&gt;&lt;br&gt;
Scala and Rust are both programming languages, but they have some key differences:&lt;/p&gt;

&lt;p&gt;Scala:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Object-Oriented and Functional programming language&lt;/li&gt;
&lt;li&gt;Runs on the Java Virtual Machine (JVM)&lt;/li&gt;
&lt;li&gt;Has strong support for functional programming concepts and is used for building complex applications&lt;/li&gt;
&lt;li&gt;Known for its expressiveness and concise syntax&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rust:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;System programming language&lt;/li&gt;
&lt;li&gt;Runs natively and can be used for low-level programming tasks such as creating operating systems or game engines&lt;/li&gt;
&lt;li&gt;Offers low-level control and performance optimization along with modern programming abstractions&lt;/li&gt;
&lt;li&gt;Known for its focus on safety and security by providing memory safety guarantees without a garbage collector&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
In conclusion, Scala is more suitable for building complex applications that need functional programming abstractions, while Rust is more appropriate for system-level programming tasks where safety and performance are crucial.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>rust</category>
      <category>scala</category>
      <category>devops</category>
    </item>
    <item>
      <title>Configuring worker plugins in Vite 2.8</title>
      <dc:creator>Daniel Onugha</dc:creator>
      <pubDate>Thu, 02 Feb 2023 06:05:18 +0000</pubDate>
      <link>https://dev.to/danielonugha0/configuring-worker-plugins-in-vite-28-5dic</link>
      <guid>https://dev.to/danielonugha0/configuring-worker-plugins-in-vite-28-5dic</guid>
      <description>&lt;p&gt;Assuming you have made use of the framework &lt;code&gt;vite&lt;/code&gt;for frontend works, you should have already gotten used to the service workers, both the installation and registering it.&lt;br&gt;&lt;br&gt;
Vite plugins extend their well-designed interface with a few Vite-specific options. With this, you can work and write a &lt;code&gt;vite plugin&lt;/code&gt;once and it will function.&lt;br&gt;
This article will explore how to properly configure worker plugins with Vite for a functional progressive web application (PWA).&lt;/p&gt;

&lt;p&gt;What is Vite?&lt;br&gt;
Vite is a build tool that is designed to channel the gap between current and next-generation web development. It centers on providing a faster and more performant skill for developers and current web projects.&lt;br&gt;
Supposing you have used the Vue framework before, you should have used the Vue CLI to develop big and complex projects. While the Vue CLI is a great build tool Vue CLI which stands for (command line interface) is an excellent tool for building Vue developers to manage webpack internals, Evan You, the creator of Vue, created a lightning-fast build tool called Vite in 2020 and also open source JavaScript framework.&lt;/p&gt;

&lt;p&gt;What is PWA?&lt;br&gt;
Progressive web application (PWA), from my own view, I see PWA as a technology that brings web and mobile development to a new level and a new generation.  PWAs define web apps that use manifests, service workers, and other web-platform features in combination with progressive enhancement, giving users a relatively almost the same experience as native applications.&lt;br&gt;
Some benefits of using a PWA include easy and fast installation, progressive enhancement, network independence, security, and SEO benefits.&lt;/p&gt;

&lt;p&gt;What are service workers?&lt;br&gt;
You may think of a service worker as a proxy server that stands within a web app, the browser, and the network, when available. A service worker's goal is to create productive offline experiences, update assets on the server, intercept network requests, and take action based on whether or not the network is available.&lt;/p&gt;

&lt;p&gt;What is a manifest?&lt;br&gt;
Web app manifests are the portion of a collection of PWAs that provide information about the web app in a JSON text file. A PWA manifest consists of its name, version, description, icons, and any other essential resources that are related to the application.&lt;/p&gt;

&lt;p&gt;Project setup&lt;br&gt;
Now that we know all the technical argot encircling progressive web applications, we’ll learn and know how to configure worker plugins with Vite.&lt;/p&gt;

&lt;p&gt;We will be using VitePWA plugin, in our demo, created by Anthony Fu. This plugin helps to attach service workers in a Vite app for handling:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Caching resources
- Offline support
- Receive push notifications when new content is available.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Scaffolding the Vite project &lt;br&gt;
If you don’t have a Vite-based project already, that you’d like to use to configure your PWA, you can create one from any of the available templates. You can also create a new Vite project byrunning the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm create vite@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Whenever I’m creating my Vite app, I choose the Vue framework and the JavaScript variant. After the app scaffold is completed, install the application dependencies in the project with the command below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In order to make the local server, you can run the following command below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Configuration&lt;br&gt;
Let’s proceed and configure our application's worker plugins, VitaPWA.&lt;/p&gt;

&lt;p&gt;Firstly, we have to install the package as a dev dependency by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i vite-plugin-pwa -D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
// vite.config.js
import legacy from '@vitejs/plugin-legacy'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    legacy({
      targets: ['defaults', 'not IE 11']
    })
  ]
})

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The plugin also accept presets containing different plugins as a solo element. This is utile for the complicated attributes (such as framework integration) that are carried out using various plugins.&lt;br&gt;
False plugins will be overlooked, which can be used to simply enable or disable plugins.&lt;/p&gt;

&lt;p&gt;Registering the workers for our Vite app&lt;br&gt;
Now, that we have installed the worker's plugin, we will need to register the service workers. The &lt;code&gt;site-plugin-PWA&lt;/code&gt;plugin registers the service worker automatically using the &lt;code&gt;injectRegister&lt;/code&gt;configuration option, which is not mandatory.&lt;/p&gt;

&lt;p&gt;To register the service workers, update the &lt;code&gt;vite.config.js&lt;/code&gt; or &lt;code&gt;vite.config.ts&lt;/code&gt; file, according to the variant you preferred upon project scaffolding. Import &lt;code&gt;VitePWA&lt;/code&gt; from &lt;code&gt;vite-plugin-PWA&lt;/code&gt; and the plugin so that it looks like the code below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
mport { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { VitePWA } from 'vite-plugin-pwa';

export default defineConfig({
  plugins: [vue(), VitePWA({ registerType: 'autoUpdate' })],
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since we have registered our &lt;code&gt;Vite-plugin-PWA&lt;/code&gt;with the code block above, we can now make use of it to generate its web app manifest and place it in front as against building an app.&lt;/p&gt;

&lt;p&gt;You can build your Vite app using the command below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run build

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this little configuration of the &lt;code&gt;vite-plugin-pwa&lt;/code&gt;plugin, our application will now be able to create the web app manifest, put it at the entry point upon app build, create the service worker, and register it in the browser.&lt;br&gt;
If the version of your  &lt;code&gt;vite-plugin-PWA&lt;/code&gt; is ≤v0.12.2 or less, then make use of  &lt;code&gt;injectRegister&lt;/code&gt; to configure the  &lt;code&gt;registerType&lt;/code&gt;  as stated below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
impor t { VitePWA } from 'vite-plugin-pwa'

export default defineConfig({
  plugins: [
    ...,
    VitePWA({
      injectRegister: 'auto'
    })
  ]
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We are going to build the Vite application using the code block below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you build an app, a  &lt;code&gt;dist&lt;/code&gt;folder is a folder that holds or handles the different files created, which includes the JavaScript variant for the service worker file and the app manifest.&lt;/p&gt;

&lt;p&gt;Now, that we have finally configured the service worker successfully with our vite application created earlier, the app can function completely as work offline and as a functional web application.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;vite-plugin-pwa&lt;/code&gt;offers a convenient and easy way to build a standard web application with Vite into a wholly developed PWA.&lt;br&gt;
In as much as building a good web application look difficult, it would be nice to make use of this framework &lt;code&gt;VitePWA Plugin&lt;/code&gt; Just install the plugin and watch it do all the bulky work.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>web3</category>
      <category>crypto</category>
      <category>blockchain</category>
    </item>
    <item>
      <title>Building a Login System using Redux</title>
      <dc:creator>Daniel Onugha</dc:creator>
      <pubDate>Wed, 26 Oct 2022 08:38:33 +0000</pubDate>
      <link>https://dev.to/danielonugha0/building-a-login-system-using-redux-5ce3</link>
      <guid>https://dev.to/danielonugha0/building-a-login-system-using-redux-5ce3</guid>
      <description>&lt;p&gt;A login is a set of credentials used to authenticate a user. Most often, these consist of a username and password. However, a login may include other information, such as a PIN number, passcode, or passphrase. React Redux is the official React binding for Redux. It allows React components to read data from a Redux Store, and dispatch Actions to the Store to update data. Redux helps apps to scale by providing a sensible way to manage state through a unidirectional data flow model. React Redux is conceptually simple.&lt;br&gt;
 When a login fails (i.e., the username and password combination does not match a user account), the user is disallowed access. Redux is an open-source JavaScript library for managing and centralizing application state. It is most commonly used with libraries such as React or Angular for building user interfaces. &lt;/p&gt;

&lt;p&gt;Goal&lt;br&gt;
In this article we are going to display how to create a Login System using Redux in React Applications.&lt;/p&gt;

&lt;p&gt;Table of Content&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;Creating our React App&lt;/li&gt;
&lt;li&gt;Creating our Login  Application&lt;/li&gt;
&lt;li&gt;Login Value Inputs&lt;/li&gt;
&lt;li&gt;Implementing Redux &lt;/li&gt;
&lt;li&gt;Final Outputs&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Installing and Setting up React&lt;br&gt;
We will create a new React app with the command below:&lt;br&gt;
&lt;code&gt;npx create-react-app Login System&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We have successfully installed our react application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating our Components&lt;/strong&gt;&lt;br&gt;
We created the basic Components index.js and the App.js&lt;/p&gt;

&lt;p&gt;The full index.js file&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjys6w14og827u8md1qwz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjys6w14og827u8md1qwz.png" alt="Image description" width="800" height="244"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Below is the App.js after linking the all the folders and files to it  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fexpavooarnhjzmprsz74.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fexpavooarnhjzmprsz74.png" alt="App.js" width="800" height="309"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Creating our Component folder&lt;br&gt;
Next Create a Component folder inside the src folder and name it Login.js. Open the file, copy the code below and paste it inside:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
import React, { useState } from "react";
import { useDispatch } from "react-redux";
import { login } from "../features/userSlice";
import "./Login.css";
const Login = () =&amp;gt; {
    const [name, setName] = useState("");
    const [email, setEmail] = useState("");
    const [password, setPassword] = useState("");
    const dispatch = useDispatch();
    const handleSubmit = (e) =&amp;gt; {
      e.preventDefault();
      dispatch(
        login({
         name: name,
         email: email,
         password: password,
         loggedIn: true,
        })
      );
    };

    return (
        &amp;lt;div className="login"&amp;gt;
          &amp;lt;form className="login_form" onSubmit={(e) =&amp;gt; handleSubmit(e)}&amp;gt;
            &amp;lt;h1&amp;gt;Login Here 📝&amp;lt;/h1&amp;gt;
            &amp;lt;input
             type="name" 
             placeholder="Name" 
             value={name} 
             onChange={(e) =&amp;gt; setName(e.target.value)}
            /&amp;gt;
            &amp;lt;input 
             type="email"
             placeholder="Email"
             value={email}
             onChange={(e) =&amp;gt; setEmail(e.target.value)} 
            /&amp;gt;
            &amp;lt;input
             type="password"
             placeholder="Password"
             value={password}
             onChange={(e) =&amp;gt; setPassword(e.target.value)} 
            /&amp;gt;
            &amp;lt;button type="submit" className="submit_btn"&amp;gt;
              submit
            &amp;lt;/button&amp;gt;
          &amp;lt;/form&amp;gt;
        &amp;lt;/div&amp;gt;
    );
};
export default Login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Creating a Login button for our Form&lt;br&gt;
Here we’re creating this using a type submit button using a special class “btn”, below are the block of codes used:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;button type="submit" className="submit_btn"&amp;gt;
   submit
&amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We created a Login form in the code block above.&lt;br&gt;
Styling the Login.js to beautify it, create a file under the Components folder named Login.css:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.login {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100vh;
    align-items: center;
    font-family: "Inter";
}
.login_form {
    display: flex;
    flex-direction: column;
}
.login_form&amp;gt;h1 {
    font-size: 35px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    letter-spacing: -1px;
}
.login_form&amp;gt;input {
    min-width: 380px;
    padding: 20px 0;
    padding-left: 15px;
    margin-bottom: 10px;
    outline: none;
    border: 1px solid rgba(0, 0, 0, 0.24);
    font-family: "Inter";
    border-radius: 2px;
    font-size: 15px;
}
.submit_btn {
    padding: 17px 30px;
    margin-top: 10px;
    background: black;
    border: none;
    color: white;
    font-size: 14px;
    font-family: "Inter";
    border-radius: 3px;
}`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s also add some css to the App, so we start by creating a new file under the Component folder and we should name it App.css.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4yq38athnth7ms7f7wfz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4yq38athnth7ms7f7wfz.png" alt="Image description" width="800" height="189"&gt;&lt;/a&gt;&lt;br&gt;
The code block above is basically adding styles to our App.&lt;/p&gt;

&lt;p&gt;Creating a Logout File for our Form&lt;/p&gt;

&lt;p&gt;Still the same way we created our Login.js file, create a file under the Components folder called Logout.js and it’s css (Logout.css):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from "react";
import { useDispatch, useSelector } from "react-redux";
import { logout, selectUser } from "../features/userSlice";
import "./Logout.css";
const Logout = () =&amp;gt; {
  const user = useSelector(selectUser);
  const dispatch = useDispatch();
  const handleLogout = (e) =&amp;gt; {
    e.preventDefault();
    dispatch(logout());
  };
    return (
        &amp;lt;div className="logout"&amp;gt;
          &amp;lt;h1&amp;gt;
            Welcome &amp;lt;span className="user_name"&amp;gt;{user.name}&amp;lt;/span&amp;gt;
          &amp;lt;/h1&amp;gt;{""}
          &amp;lt;button className="logout_button" onClick={(e) =&amp;gt; handleLogout(e)}&amp;gt;
            Logout
          &amp;lt;/button&amp;gt;
        &amp;lt;/div&amp;gt;
    );
};
export default Logout;`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Above is the full code block of our Logout.js file.&lt;/p&gt;

&lt;p&gt;Creating the Logout button for our Form&lt;/p&gt;

&lt;p&gt;Here we’re creating the Logout button, with the blocks of codes below;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;button className="logout_button" onClick={(e) =&amp;gt; handleLogout(e)}&amp;gt;
  Logout
&amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can add the following styles inside your Logout.css file;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxyxrfobwdkpzn8rv7a5q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxyxrfobwdkpzn8rv7a5q.png" alt="Image description" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Implementing Redux&lt;br&gt;
The first step is to basically open a new folder, name it app, afterwards you create a file called store.js. After that we’re going to open another folder named features, you also create a file name userSlice.js.&lt;/p&gt;

&lt;p&gt;Redux Toolkit is available as a package on NPM for use with a module bundler or in a Node application. To download redux toolkit, you have to look at the code block below :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# NPM
npm install @reduxjs/toolkit

# Yarn
yarn add @reduxjs/toolkit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And also you have to install Redux itself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# NPM
npm install react-redux

# Yarn
yarn add react-redux
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you’re done installing it, the first thing is to import createSlice from Redux toolkit using the below block of code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { createSlice } from "@reduxjs/toolkit";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below is the userSlice.js file;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F717dsdwhyr5k057ruc1f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F717dsdwhyr5k057ruc1f.png" alt="Image description" width="800" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc80hupr47a5gry2qhpi0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc80hupr47a5gry2qhpi0.png" alt="Image description" width="800" height="161"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Above is the store.js, breaking it down we start by importing configureStore from Redux toolkit using the below code block:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { configureStore } from "@reduxjs/toolkit";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After inputting all the code and making sure our App is working.&lt;br&gt;
This would be the result:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj4skfb0m2q8vo3vuemm4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj4skfb0m2q8vo3vuemm4.png" alt="Image description" width="512" height="406"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And, after clicking the submit button:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ikpfx01ncmuqtr8id7c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ikpfx01ncmuqtr8id7c.png" alt="Image description" width="502" height="125"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you are done with the App, you click on Logout, it takes you back to a fresh form:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftfc9soqgtkw4mecetnmu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftfc9soqgtkw4mecetnmu.png" alt="Image description" width="636" height="458"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Conclusion&lt;br&gt;
A Login form is used to enter authentication credentials to access a restricted page or form. The login form contains a field for the username and another for the password. When the login form is submitted its underlying code checks that the credentials are authentic, giving the user can access the restricted page.&lt;br&gt;
In this article, we learnt about User Login using React and Redux.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>redux</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Generating QR Codes using React</title>
      <dc:creator>Daniel Onugha</dc:creator>
      <pubDate>Sun, 25 Sep 2022 16:56:36 +0000</pubDate>
      <link>https://dev.to/danielonugha0/generating-qr-codes-using-react-51ik</link>
      <guid>https://dev.to/danielonugha0/generating-qr-codes-using-react-51ik</guid>
      <description>&lt;p&gt;Generating QR Codes using React&lt;br&gt;
QR code (quick response code) were the first retailer here to offer QR codes in their advertising, it can be read easily by a digital device and which stores information as a series of pixels in a square-shaped grid.&lt;br&gt;
It’s a machine-readable code consisting of any array of black and white squares, typically used for sorting URLs or other information for reading by the camera on a smartphone.&lt;br&gt;
A QR code (an initialism for quick response code) is a type of matrix barcode (or two-dimensional barcode)invented in 1994 by the Japanese automotive company Denso Wave. A barcode is a machine-readable optical label that can contain information about the item to which it is attached. In practice, QR codes often contain data for a locator, identifier, or tracker that points to a website or application. QR codes use four standardized encoding modes (numeric, alphanumeric, byte/binary, and kanji) to store data efficiently; extensions may also be used.&lt;br&gt;
Goal&lt;br&gt;
In this article, we are going to display how to create QR Codes in  React.js applications.&lt;/p&gt;

&lt;p&gt;Table of Content &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;Installing and Setting up React&lt;/li&gt;
&lt;li&gt;Creating our Components&lt;/li&gt;
&lt;li&gt;Using the QR code package&lt;/li&gt;
&lt;li&gt;Making use of the QR Code Reader&lt;/li&gt;
&lt;li&gt;Conclusion &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Installing and Setting up React&lt;br&gt;
The next step is to install our react before we create our form application. Note there are two ways we can use this library: NPM and CDN, but in this article, we will install the application using NPM.&lt;/p&gt;

&lt;p&gt;Install the React application using the following command:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app qrcode
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We have successfully installed our react application under QR code.&lt;/p&gt;

&lt;p&gt;Creating our Components&lt;br&gt;
Here we’ll have to create our component folder, the App.js and the Index.js which we’ll use in working &lt;br&gt;
 This is the index.js format:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_16606828A80289600CD044CCD5498A269D0D3B0E14FCFD7CA55554726289C76E_1662289713233_2022-09-04%2B1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_16606828A80289600CD044CCD5498A269D0D3B0E14FCFD7CA55554726289C76E_1662289713233_2022-09-04%2B1.png" alt="Index.js"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Below is the App.js file &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_16606828A80289600CD044CCD5498A269D0D3B0E14FCFD7CA55554726289C76E_1662290163391_2022-09-04%2B2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_16606828A80289600CD044CCD5498A269D0D3B0E14FCFD7CA55554726289C76E_1662290163391_2022-09-04%2B2.png" alt="App.js"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Breaking it down in the index.js, I can pass in text which is meant to represent the value of the QR code, because every QR code represent a value either numeric, alphanumeric, byte/binary or kanji. Our own is representing “worn off keys” , then the QR code represent worn off keys will then be displayed&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;App text="worn off keys" /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In the App.js, to use the QR code package [import QRCode from ‘qrcode’] that we imported to be able to generate a proper source and then setting it inside the variable  using the “setSrc” function below;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;useEffect(() =&amp;gt; {
  QRCode.toDataURL(text).then(setSrc);
}, []);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This is how our App looks .&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_16606828A80289600CD044CCD5498A269D0D3B0E14FCFD7CA55554726289C76E_1662406610629_2022-09-05%2B3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_16606828A80289600CD044CCD5498A269D0D3B0E14FCFD7CA55554726289C76E_1662406610629_2022-09-05%2B3.png" alt="Our App"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The size of the QR Code is the depending on size of the data provided in the App.js text code block because it gets to store more data;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;
    App text="wornoffkeys.comwornoffkeys.comwornoffkeys.comwornoffkeys.comwornoffkeys.com" /&amp;gt;
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Conclusion&lt;br&gt;
QR codes can provide more information about the product or service without a sweat, and the information quickly goes to the user's device. Basically, QR codes promote interaction and engagement through the mobile phone. This type of marketing strategy enables businesses to transfer information to the user.&lt;/p&gt;

&lt;p&gt;Today we’re able to produce QR codes using the  QR code` library and React, as we’ve seen. &lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>github</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
