<?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: Nehemiah Dauda</title>
    <description>The latest articles on DEV Community by Nehemiah Dauda (@meganad60).</description>
    <link>https://dev.to/meganad60</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%2F1112914%2Ff46ba302-bf3f-48c0-ab8f-bed1e317252a.jpg</url>
      <title>DEV Community: Nehemiah Dauda</title>
      <link>https://dev.to/meganad60</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/meganad60"/>
    <language>en</language>
    <item>
      <title>The Basics of React Props for Beginners</title>
      <dc:creator>Nehemiah Dauda</dc:creator>
      <pubDate>Mon, 04 Sep 2023 02:12:48 +0000</pubDate>
      <link>https://dev.to/meganad60/the-basics-of-react-props-for-beginners-3j01</link>
      <guid>https://dev.to/meganad60/the-basics-of-react-props-for-beginners-3j01</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;React applications are developed using independent and reusable components. These components can be nested within another component, thereby creating parent and child components.&lt;/p&gt;

&lt;p&gt;The purpose of this tutorial is on props. Props is an important React tool that helps with the flow of data from the parent component to the child component(s). Props enable the development of dynamic data and styles for reusable child components. You don’t have to repeat yourself creating multiple components for different styles and data.&lt;/p&gt;

&lt;p&gt;This tutorial provides a basic insight into props. As you study through this tutorial, you will learn the meaning of props with practical examples of applying props to your application.&lt;/p&gt;

&lt;p&gt;Furthermore, you will get to understand what parent and child components mean, the features of props, and benefits as well. Don’t worry if you are confused about when to use props. This tutorial has you covered. You will learn the purpose of props and when to apply them in your application.&lt;/p&gt;

&lt;p&gt;This tutorial targets beginners as well as mid-react developers who want to improve their understanding of what props entail.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Prerequisite&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To get a better understanding of this tutorial, you should be conversant with basic React structures such as components. You should know the use of components and how to create them.&lt;/p&gt;

&lt;p&gt;Also, you should be familiar with basic JavaScript tools such as object, and object destructuring.&lt;/p&gt;

&lt;p&gt;Your familiarity with the above terms and tools will further boost your understanding of this tutorial.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/meganad60/the-basics-of-react-props-for-beginners-3j01#what-is-props"&gt;What is Props?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/meganad60/the-basics-of-react-props-for-beginners-3j01#what-is-the-parent-and-child-component"&gt;What is the parent and child component?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/meganad60/the-basics-of-react-props-for-beginners-3j01#features-of-props"&gt;Features of props&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Benefits of using props&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/meganad60/the-basics-of-react-props-for-beginners-3j01#how-to-apply-props-with-practical-examples"&gt;How to apply props&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/meganad60/the-basics-of-react-props-for-beginners-3j01#when-to-apply-props"&gt;When to apply props&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is Props?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Props stand for &lt;strong&gt;properties&lt;/strong&gt;. They are arguments passed to React components and return as an object. Props enables you to store and pass data from the parent component to the child component(s).&lt;/p&gt;

&lt;p&gt;A parent component can call and render a child component multiple times. Thus, using props enables you to create dynamic content and styles for each reusable child component.&lt;/p&gt;

&lt;p&gt;Props are immutable i.e., they are read-only and cannot be updated or modified upon user request.&lt;/p&gt;

&lt;p&gt;To better understand props, let’s take a look at HTML element attributes. Note that HTML element attributes can also be referred to as properties. They work similarly to props, but props are passed as an argument to components.&lt;/p&gt;

&lt;p&gt;Examine the HTML example 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;img src="/imagesrc" height="20px" width="20px"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;img&lt;/code&gt; tag contains some attributes–src, height, and width. These attributes determine what image and how the image will be displayed on the browser.&lt;/p&gt;

&lt;p&gt;Now, examine the React component–&lt;code&gt;Greetings&lt;/code&gt;–below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Greetings(props){

return(
    &amp;lt;h1&amp;gt;{props.text}&amp;lt;/h1&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above React component accepts an argument–&lt;code&gt;props&lt;/code&gt;, which can be any name of your choice. Next, &lt;code&gt;props&lt;/code&gt; is returned as an object with the &lt;strong&gt;dot (.)&lt;/strong&gt; notation, and &lt;code&gt;text&lt;/code&gt; value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function App(){

  return(
    &amp;lt;Greetings text='Welcome' /&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Furthermore, another component–the App component above–calls and renders the Greetings component with a &lt;code&gt;text&lt;/code&gt; attribute assigned to a string value–&lt;code&gt;Welcome&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Hence, the above codes will display &lt;strong&gt;Welcome&lt;/strong&gt; as a heading on your browser.&lt;/p&gt;

&lt;p&gt;Thus, Props functionality enables the easy flow of data from the parent component to the child component(s). The Parent component through props determines what the child component(s) displays and how the child component(s) will be displayed on the browser.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is the parent and child component?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Components is a core structure of the React application. Components are independent and reusable JavaScript codes used in creating user interfaces with React.&lt;/p&gt;

&lt;p&gt;The App.js file is an example of a React component. The App.js file is the root component that calls and renders other components on the browser. This makes the App.js file a parent component to all other components.&lt;/p&gt;

&lt;p&gt;A parent component is any component that contains one or more nested component(s). In other words, a parent component calls and renders another component(s).&lt;/p&gt;

&lt;p&gt;A child component is a component that is nested within another component. In other words, a child component is called and rendered in another component.&lt;/p&gt;

&lt;p&gt;The below code example identifies a parent and a child component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function ChildComponent(){
  return(
    &amp;lt;p&amp;gt;This is a child component&amp;lt;/p&amp;gt;
  )
}

function ParentComponent(){
  return(
    &amp;lt;ChildComponent /&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above example contains two components–&lt;code&gt;ParentComponent&lt;/code&gt; and &lt;code&gt;ChildComponent&lt;/code&gt;. The &lt;code&gt;ParentComponent&lt;/code&gt; calls and renders the &lt;code&gt;ChildComponent&lt;/code&gt;, making the &lt;code&gt;ChildComponent&lt;/code&gt; nested within the &lt;code&gt;ParentComponent&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Features of props&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Below are some notable features of props that are important to know.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Immutable:&lt;/strong&gt; Props are immutable. In other words, props are read-only and cannot be modified or updated upon user request. Thus, what is displayed on the browser remains static and unchanged.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The uni-directional flow of data:&lt;/strong&gt; Props pass data in a one-way flow i.e. from the parent component to the child component(s). Thus, the child component(s) only receives data and cannot pass data to the parent component.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Component’s argument:&lt;/strong&gt; Props are passed as an argument in React components and returned as an object with the dot notation.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Benefits of using props&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Props is a helpful tool when creating React components. Below are some of the benefits of using props.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Easy flow of data:&lt;/strong&gt; Props create a means of connection and communication between two or more components i.e. the parent and child components. Thus, props enable the easy flow of data from one component (the parent component) to another (the child component(s)).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Dynamic contents:&lt;/strong&gt; Props allow you to render different data and styles for your reusable component. For instance, a component can be reused multiple times with each containing different contents and styles.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Fewer codes:&lt;/strong&gt; Instead of creating multiple components with their unique contents, props allow you to create a single and reusable child component. Each reusable component can contain its unique contents, thereby reducing the amount of codes to be written.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How to apply props with practical examples&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this section, let’s further examine and learn how to apply props in React applications.&lt;/p&gt;

&lt;p&gt;The App.js file is where we shall be writing all our codes.&lt;/p&gt;

&lt;p&gt;Please note that you can also create components by creating a new &lt;strong&gt;‘.js&lt;/strong&gt;’ file in the src directory. In this case, the created component will be exported and then imported into the parent component or the App.js file.&lt;/p&gt;

&lt;p&gt;But for this tutorial, all components will be created in the App.js file.&lt;/p&gt;

&lt;p&gt;Also, note that all components must begin with a capital alphabet. This is the standard way of creating components according to the official doc of React. Read more about React components &lt;a href="https://legacy.reactjs.org/docs/components-and-props.html"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let’s get started&lt;/p&gt;

&lt;p&gt;In the App.js file, create an &lt;code&gt;Item&lt;/code&gt; component with &lt;code&gt;props&lt;/code&gt; passed as its argument. Then return an object just as the code example below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Item(props){

  return(
    &amp;lt;p&amp;gt;Product name: {props.name}&amp;lt;/p&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, in the return method of the App.js component, insert the below codes to render the &lt;code&gt;Item&lt;/code&gt; component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function App() {
  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;Item name='Cars' /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;Item&lt;/code&gt; component becomes the child component of the &lt;code&gt;App&lt;/code&gt; component—which then becomes the parent component. The &lt;code&gt;App&lt;/code&gt; component calls and renders the &lt;code&gt;Item&lt;/code&gt; component while also passing the value for name.&lt;/p&gt;

&lt;p&gt;Below is the complete code for the App.js file.&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 './App.css';

function Item(props){
  return(
    &amp;lt;h3&amp;gt;Item name: {props.name}&amp;lt;/h3&amp;gt;
  )
}

function App() {
  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;Item name='Cars' /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

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

&lt;/div&gt;



&lt;p&gt;Save your work and start your server. Open your browser and the below image displays on your screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pq92pMkR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hfla8s6hcdejrtby853m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pq92pMkR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hfla8s6hcdejrtby853m.png" alt="Props 1" width="800" height="483"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Props also enable you to apply different data to each reusable child component. See the code example below.&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 './App.css';

function Item(props){
  return(
    &amp;lt;h3&amp;gt;Item name: {props.name}&amp;lt;/h3&amp;gt;
  )
}

function App() {
  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;Item name='Car' /&amp;gt;
      &amp;lt;Item name='Phone' /&amp;gt;
      &amp;lt;Item name='Computer' /&amp;gt;
      &amp;lt;Item name='Table' /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

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

&lt;/div&gt;



&lt;p&gt;The above code shows &lt;code&gt;Item&lt;/code&gt; component reused multiple times with different values for the &lt;code&gt;name&lt;/code&gt; attribute.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wE1QtLLF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/owhng2xicwv4lvlk71j6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wE1QtLLF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/owhng2xicwv4lvlk71j6.png" alt="Props 2" width="800" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can further create dynamic styles for each reusable child component. See the code example below.&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 './App.css';

function Item(props){
  return(
    &amp;lt;h3 style={props.style}&amp;gt;Item name: {props.name}&amp;lt;/h3&amp;gt;
  )
}

function App() {
  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;Item name='Car' style={{color: 'green'}} /&amp;gt;
      &amp;lt;Item name='Phone' style={{color: 'red'}} /&amp;gt;
      &amp;lt;Item name='Computer' style={{color: 'blue'}} /&amp;gt;
      &amp;lt;Item name='Table' style={{color: 'grey'}} /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

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

&lt;/div&gt;



&lt;p&gt;In the above code, the child component–&lt;code&gt;Item&lt;/code&gt; returned a &lt;code&gt;{props.style}&lt;/code&gt; object assigned to the style attribute in the &lt;code&gt;h3&lt;/code&gt; tag. Next, the parent component calls the child component multiple times with each containing a style attribute with different styles.&lt;/p&gt;

&lt;p&gt;Note that CSS styles for props value must be an object.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6U3XoxNx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nxox3gnui1td64s7htse.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6U3XoxNx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nxox3gnui1td64s7htse.png" alt="Props 3" width="800" height="482"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;When to apply props&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;You must be wondering when to apply props in your application. The following points give us basic insight on when to apply props.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Mutability of data&lt;/strong&gt;&lt;br&gt;
Props deal with immutable data i.e. read-only data. Thus, as a developer, you need to understand the nature of your data before you apply props in your component. If your data is mutable, then there are other React tools to use. But if your data is immutable, props can be applied to your component.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Nature of Component&lt;/strong&gt;&lt;br&gt;
A developer also needs to understand the nature of your component before you can use props in your application. If your component is reusable and will contain different static contents, props is a good choice to use.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In summary, props is a great React tool that connects the parent and the child component(s). Props ensure the flow of data from the parent to the child component(s) and also enable dynamic rendering of contents and styles for reusable components.&lt;/p&gt;

&lt;p&gt;Thus, this tutorial walked us through the basic insight into what props entail. We looked at the meaning, features and benefits of props. We also study what the parent and child component means in general, and we learn when to apply props in our application.&lt;/p&gt;

&lt;p&gt;I hope through this tutorial, you can now understand and apply props with ease in your React application. Kudos for adding another knowledge to your React skills. Explore other React tools as well such as states, hooks and amongst others.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Additional resources&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://legacy.reactjs.org/docs/components-and-props.html"&gt;Components and Props&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.w3scools.com/react/react_props.asp"&gt;w3schools React Props&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://itnext.io/what-is-props-and-how-to-use-it-in-react-da307f500da0"&gt;What is "Props" and how to use it in React?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://refine.dev/blog/react-props/"&gt;React Props Explained with Examples&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>Practical steps on how to apply the useParams hook of React router.</title>
      <dc:creator>Nehemiah Dauda</dc:creator>
      <pubDate>Mon, 21 Aug 2023 23:56:15 +0000</pubDate>
      <link>https://dev.to/meganad60/practical-steps-on-how-to-apply-the-useparams-hook-of-react-router-101o</link>
      <guid>https://dev.to/meganad60/practical-steps-on-how-to-apply-the-useparams-hook-of-react-router-101o</guid>
      <description>&lt;p&gt;The useParams hook is essential in developing a friendly user interface with React. Hence, an important knowledge React developers must be familiar with. The useParams hook enables the development of complex React interface with multiple parameters such as e-commerce and blogging websites.&lt;/p&gt;

&lt;p&gt;This tutorial focus on providing the practical steps and knowledge on how to apply the useParams hook in React applications. This tutorial will cover the following topics:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://dev.to/meganad60/practical-steps-on-how-to-apply-the-useparams-hook-of-react-router-101o#what-is-the-useparams-hook"&gt;1. What is the useParams hook?&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://dev.to/meganad60/practical-steps-on-how-to-apply-the-useparams-hook-of-react-router-101o#requirements-to-apply-the-useparams-hook"&gt;2. Requirements to apply the useParams hook&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://dev.to/meganad60/practical-steps-on-how-to-apply-the-useparams-hook-of-react-router-101o#benefits-of-using-the-useparams-hook"&gt;3. Benefits of using the useParams hook&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://dev.to/meganad60/practical-steps-on-how-to-apply-the-useparams-hook-of-react-router-101o#practical-steps-on-how-to-apply-the-useparams-hook-in-react"&gt;4. Practical steps on how to apply the useParams hook.&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Prerequisite:&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This is a beginner-friendly tutorial for those interested in learning React and how to apply the useParams hook of React-router. Although to get the best from this tutorial, it is important to be familiar with some basic React and JavaScript tools. These tools include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;React Routing,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Map function, and&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Destructuring.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You must also be familiar with HTML and CSS. Thus, I recommend learning the above concepts first before moving ahead with this tutorial.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is the useParams hook?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The useParams hook is a React router hook that is used to create and access multiple parameters of a website. In essence, the useParams hook gives access to multiple contents in the same URL path. The useParams hook enables each parameter to have a unique identification. Through this unique identification, each parameter can be accessed and rendered in the same URL path.&lt;/p&gt;

&lt;p&gt;E-commerce and Blog apps are examples of applications with multiple parameters. Other examples where the useParams hook is also applicable include &lt;strong&gt;Learning Management System (LMS)&lt;/strong&gt;–i.e. online tutorial sites, search buttons of websites, articles/newspapers websites, and amongst others.&lt;/p&gt;

&lt;p&gt;A blog app, for instance, contains several blogs. Each blog will have a unique id, through which each blog can be accessed.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Requirements to apply the useParams hook&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To apply the useParams hook in your React app, some basic tools and libraries are required. In this section, we shall be looking at these basic requirements.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. React-router-dom
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;react-router-dom&lt;/code&gt; is an external React library that provides routings in React applications. The &lt;code&gt;react-router-dom&lt;/code&gt; comes with the useParams hook. Thus, to apply the useParams hook, react-router-dom must be installed in your React app. This section below provides the guide to &lt;a href="https://dev.to/meganad60/practical-steps-on-how-to-apply-the-useparams-hook-of-react-router-101o#practical-steps-on-how-to-apply-the-useparams-hook-in-react"&gt;set up React app and installing&lt;/a&gt; react-router-dom.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Component
&lt;/h3&gt;

&lt;p&gt;A Component is a series of JavaScript codes that returns HTML elements. Components in React determine the contents to be displayed on your browser.&lt;/p&gt;

&lt;p&gt;To apply the useParams hook, create a component and import the useParams into the component. Next, assign a variable to useParams method using object destructuring. See the code example below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useParams } from 'react-router-dom';

function Blog(){
  let { blogid } = useParams();

  return&amp;lt;p&amp;gt;my unique id is {blogid}&amp;lt;/p&amp;gt;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Route tag
&lt;/h3&gt;

&lt;p&gt;The Route tag signifies the URL path in your browser. The Route tag accepts two attributes. They include the path attribute and the element attribute. The path attribute is assigned to a URL path. The element attribute is assigned to the component to be rendered.&lt;/p&gt;

&lt;p&gt;To apply the useParams hook, the path attribute will also contain a placeholder. What the placeholder does is it returns dynamic content based on the value that matches it. See the example 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;Routes&amp;gt;
    &amp;lt;Route path='/blog/:blogid' element={&amp;lt;Blog /&amp;gt;}&amp;gt;&amp;lt;/Route&amp;gt;
&amp;lt;/Routes&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Take note of the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;blogid&lt;/code&gt; is the placeholder and can be any name of your choice.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The placeholder usually contains &lt;code&gt;':'&lt;/code&gt; before its value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The placeholder name must match the value assigned to the useParams method in the component.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Thus, a URL path–&lt;code&gt;/blog/2&lt;/code&gt; will return the blog contents with the id number–2.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Benefits of using the useParams hook&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The useParams hook comes with a lot of benefits both to React developers and users. Below are some of the benefits of using the useParams hook.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Multiple Parameters:&lt;/strong&gt; The useParams hook is used to create multiple parameters containing dynamic contents. Thus, using the useParams hook in your applications provides users with a large pool of information in a friendly manner.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Increase app performance:&lt;/strong&gt; The useParams hook renders dynamic content without leaving the current URL. This increases the app's performance and reduces loading time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Easy Accessibility:&lt;/strong&gt; The useParams hook is a user-friendly tool that makes it easy to access multiple parameters and contents.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Fewer codes&lt;/strong&gt;: The useParams hook enables developers to create multiple parameters with few lines of code. In essence, this eliminates unnecessary repetitions and reduces the amount of codes to be written.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Practical Steps on how to apply the useParams hook in React.&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this section, we shall be building a simple e-commerce interface that display multiple products. Each product will have a unique id through which we can access them.&lt;/p&gt;

&lt;p&gt;This section will be divided into three parts.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The first part will guide us through how to create a React app.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The second part will guide us through how to create a simple e-commerce interface.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The third part will guide us through how to apply the useParams hook in our project.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's begin.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Part One—Create React project&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The below steps guide us in creating a React app and installing react-router-dom.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Step 1: Create React App&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;To create your react app, follow the below instructions.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open your terminal and create a new folder for your React app.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigate to your newly created folder and create a new React app. Use any of the commands below to create your React app.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\Username\Desktop&amp;gt;mkdir react-app
C:\Users\Username\Desktop&amp;gt;cd react-folder
C:\Users\Username\Desktop\react-folder&amp;gt;npx create-react-app my-app

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

&lt;/div&gt;



&lt;p&gt;OR&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\Username\Desktop\react-folder&amp;gt;npm init react-app my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OR&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\Username\Desktop\react-folder&amp;gt;yarn create react-app my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Take note of the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You must have node.js installed on your system before you can create a React app. If you don't have node.js on your system, visit &lt;a href="https://node.js.org"&gt;https://node.js.org&lt;/a&gt; to install it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;react-app&lt;/code&gt; and &lt;code&gt;my-app&lt;/code&gt; is the name of your folder and react app respectively. They can be any name of your choice.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Step 2: Install React-router-dom&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;The below instructions guide us to install React-router-dom in our React project.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to your app directory in your terminal.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install react-router-dom using npm or yarn.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;See the code example below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\Username\Desktop\react-folder&amp;gt;cd my-app
C:\Users\Username\Desktop\react-folder\my-app&amp;gt;npm install react-router-dom

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

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;Step 3: Start the server&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;While still in your app directory, start your React app server just as the 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;C:\Users\Username\Desktop\react-folder\my-app&amp;gt;npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yarn users:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\Username\Desktop\react-folder\my-app&amp;gt;yarn start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; use &lt;code&gt;npm&lt;/code&gt; or &lt;code&gt;yarn&lt;/code&gt; to install React dependencies and run React scripts depending on what you use to create your React app.&lt;/p&gt;

&lt;p&gt;The start script runs your react app sever on localhost:3000.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Part Two—Set up a simple e-commerce interface&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;We've successfully created our React app and installed react-router-dom. Next, We can now create a simple e-commerce interface.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Step 1: Modify index.js file&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Open your React app with any code editor of your choice and follow the below instructions to modify the index.js file.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open your index.js file in the src directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Import BrowserRouter from react-router-dom using object destructuring.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Update root const by wrapping the App component between BrowserRouter tags.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The final codes of the index.js file should look like the code example below.&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 ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import { BrowserRouter } from 'react-router-dom';

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  &amp;lt;BrowserRouter&amp;gt;
    &amp;lt;App /&amp;gt;
  &amp;lt;/BrowserRouter&amp;gt;
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;Step 2: Create Products component&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;This component will hold the data of our products. But before we go ahead with creating a &lt;code&gt;Products&lt;/code&gt; component, create an image folder first in the src directory. The image folder should contain all the necessary images to be used. Next, follow the below instructions to create the &lt;code&gt;Products&lt;/code&gt; components.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create a components folder in the src directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a Products.js file in the components folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open your Products.js file and create a Products variable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Assign Products variable to an array of objects. Each of these objects should contain a unique id, title, description, and image.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Export the Products component.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;See the code example below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Products = [
    {
        id: 1,
        title: "Product Name",
        description: "This is the description of product with an id of 1. Provident nihil minus qui consequatur non omnis maiores. Eos accusantium minus dolores iure perferendis tempore et consequatur. ",
        image:  require('../images/product-1.png')
    },
    {
        id: 2,
        title: "Product Name",
        description: "This is the description of product with an id of 2. Provident nihil minus qui consequatur non omnis maiores. Eos accusantium minus dolores iure perferendis tempore et consequatur. ",
        image:  require('../images/product-2.png')
    },
    {
        id: 3,
        title: "Product Name",
        description: "This is the description of product with an id of 3. Provident nihil minus qui consequatur non omnis maiores. Eos accusantium minus dolores iure perferendis tempore et consequatur. ",
        image: require('../images/product-3.png')
    }
]

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

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;Step 3: Create a card component&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;The essence of the card component is to loop through our products and render them in an organized way. The following instructions guide us on how to create the card component.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create a Card.js file in the components directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open the Card.js file and import the Products component.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a Card function with a return statement.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a productItems variable before the return method in the card function.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Assign productItems variable to a map function that iterates through our Products. The map function should be like the code example below.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const productItems = Products.map(store =&amp;gt;{
        const {id, title, description, image} = store;

        return(
            &amp;lt;div key={ id } className="card"&amp;gt;
                &amp;lt;img src={image} alt=""&amp;gt;&amp;lt;/img&amp;gt;
                &amp;lt;h3&amp;gt;{title}&amp;lt;/h3&amp;gt;
                &amp;lt;p&amp;gt;{description}&amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
        )
    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, Create a section tag in the return method of the Card function. In between the section tags, should be our &lt;code&gt;productItems&lt;/code&gt; in curly braces. Don't also forget to export Card component.&lt;/p&gt;

&lt;p&gt;Our final codes for the Card.js file will be like the code example below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Products from "./Products";

function Card(){

    const productItems = Products.map(store =&amp;gt;{
        const {id, title, description, image} = store;

        return(
            &amp;lt;div key={ id } className="card"&amp;gt;
                &amp;lt;img src={image} alt=""&amp;gt;&amp;lt;/img&amp;gt;
                &amp;lt;h3&amp;gt;{title}&amp;lt;/h3&amp;gt;
                &amp;lt;p&amp;gt;{description}&amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
        )
    })

    return (
        &amp;lt;&amp;gt;
            &amp;lt;section className="card-section"&amp;gt;
                {productItems}
            &amp;lt;/section&amp;gt;
        &amp;lt;/&amp;gt;
    );
};

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

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;Step 4: Style the card component&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Add some CSS styles to our Card component in the index.css file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Our div tag and section tag in the Card component contains &lt;code&gt;className&lt;/code&gt; attributes. These &lt;code&gt;className&lt;/code&gt; attributes were created purposely for CSS styling.&lt;/p&gt;

&lt;p&gt;Open the index.css file in the src directory and apply the below CSS styles.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.card-section{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin: 40px;
}

.card{
  padding: 1.2rem;
  font-size: 1.2rem;
  border: 1px solid rgb(104, 101, 101);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;Step 5: Create a home page&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;The home page will serve as the default page of our app and will render our card component. The below points guide us to creating our home page&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create a pages folder in the src directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a Home.js file in the pages folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open the Home.js file and import the Card component.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a Home function with a return method. The return method should contain our Card element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Export the Home.js file.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;See the 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;import Card from "../components/Card"

const Home = () =&amp;gt; {

    return (
        &amp;lt;&amp;gt;
            &amp;lt;h1&amp;gt;Home Page&amp;lt;/h1&amp;gt;
            &amp;lt;Card /&amp;gt;

        &amp;lt;/&amp;gt;
    )
}

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

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;Step 6: Modify App.js File&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;The App.js file is the root component that determines what should be rendered on our browser. In this step, we shall modify our App.js file to render our pages. The below instructions guide us to modify our App.js component.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open your App.js file and import the Home component.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Update the return method of the App.js file to contain the Home element as seen in the code below.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import './App.css';
import Home from './pages/Home';


function App() {
  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;Home /&amp;gt;

    &amp;lt;/div&amp;gt;
  );
}

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

&lt;/div&gt;



&lt;p&gt;Save all files and navigate to localhost:3000 on your browser. The outcome will be like the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uTR_ugyL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nidpygw2jvj85qk9abyb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uTR_ugyL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nidpygw2jvj85qk9abyb.png" alt="useParams-img" width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Great work in creating our e-commerce interface. But there's still a lot of work to be done. For instance, our product description should contain lesser words and there should be a link in each card that directs us to each product. Hence, we shall be applying the useParams hook.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Part Three—Apply the useParams hook&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The useParams hook will enable us to create a user-friendly interface with permission to access each product through its unique ids. The useParams hook comes with the React-router-dom package. Thus we shall be importing the useParams hook from react-router-dom before we can apply them. Let's begin.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Step 1: Create a ProductDetail page&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;The ProductDetail page will contain and render the complete detail of each product based on its unique id. The below instructions guide us to create the ProductDetail page.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create a ProductDetail.js file in the pages folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open the ProductDetail.js file and import the following:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Products component from the component folder&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;useParams from react-router-dom using object destructuring.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create a ProductDetail function with a return method.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Assign 'id' to the useParams method in ProductDetail function, but before the return method. For example: &lt;code&gt;let { id } = useParams()&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a product variable and assign it to the find method. Example:&lt;br&gt;
&lt;code&gt;const product = Products.find(product =&amp;gt; String(product.id) === id);&lt;/code&gt;.&lt;br&gt;
The find method here is used to match the id of each product so that other details of the product can be accessed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a section tag in the return method of the ProductDetails function. The section tag should contain a key attribute that is assigned to the id in curly braces.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create the other tags that receives other product objects using dot notations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Export the ProductDetail.js file.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The final codes for the ProductDetail.js file will be like the code example below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useParams } from "react-router-dom";
import Products from "../components/Products";

function ProductDetail() {
    let { id } = useParams();
    const product = Products.find(product =&amp;gt; String(product.id) === id);

    return (
        &amp;lt;&amp;gt;
            &amp;lt;section key={id} className="details-section"&amp;gt;
                &amp;lt;img src={product.image} alt=""&amp;gt;&amp;lt;/img&amp;gt;
                &amp;lt;div&amp;gt;
                    &amp;lt;h3&amp;gt;{product.title}&amp;lt;/h3&amp;gt;
                    &amp;lt;p&amp;gt;{product.description}&amp;lt;/p&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/section&amp;gt;
       &amp;lt;/&amp;gt;
    )
}

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

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;Step 2: Style productDetail page&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Add CSS styles to beautify and organize our productDetail page in the index.css file. Note that we already gave our section tag on the productDetail page a className.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.details-section{
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 30px;
  margin: 90px;
  font-size: 1.3rem;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;Step 3: Create Routes&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Routes direct us to the URL path to access our content. We shall be creating all necessary routes in the App.js file. The below instructions guide us to create our routes.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Open the App.js file and import the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;ProductDetail from pages folder,&lt;/li&gt;
&lt;li&gt;Routes and Route from react-router-dom.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;Update the return method of the App.js function to the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a Routes tag.&lt;/li&gt;
&lt;li&gt;Create two Route tags in between Routes tags. Please note the difference between Routes and Route to avoid mixing them.&lt;/li&gt;
&lt;li&gt;Each Route tag should contain a path and an element attribute.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;See the code example below.&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 './App.css';
import Home from './pages/Home';
import ProductDetails from './pages/ProductDetails';
import { Route, Routes } from 'react-router-dom';

function App() {

  return (
    &amp;lt;div className="App"&amp;gt;

      &amp;lt;Routes&amp;gt;
        &amp;lt;Route path='/' element={&amp;lt;Home /&amp;gt;}&amp;gt;&amp;lt;/Route&amp;gt;

        &amp;lt;Route path='/product/:id' element={&amp;lt;ProductDetails /&amp;gt;}&amp;gt;&amp;lt;/Route&amp;gt;
      &amp;lt;/Routes&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default App;

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

&lt;/div&gt;



&lt;p&gt;Take note of the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Our first Route path is assigned to &lt;code&gt;'/'&lt;/code&gt;, which signifies the default URL path. The default URL path displays our Home component.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Our second Route path is assigned to &lt;code&gt;product&lt;/code&gt; with a placeholder–&lt;code&gt;:id&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Step 4: Modify the card.js component&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;The below instructions guide us to modify the card component.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the Card.js file and import Link from react-router-dom.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Insert &lt;code&gt;Link&lt;/code&gt; tag in between &lt;code&gt;p&lt;/code&gt; tag in the return method of card component. The Link tag should contain a &lt;code&gt;to&lt;/code&gt; attribute.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reduce the description words using the Slice method.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The final card component codes should be like the code example below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Link } from "react-router-dom";
import Products from "./Products";

const Card = () =&amp;gt; {


    const arrayDataItems = Products.map(store =&amp;gt;{
        const {id, title, description, image} = store;
        return(
            &amp;lt;div key={ id } className="card"&amp;gt;
                &amp;lt;img src={image} alt=""&amp;gt;&amp;lt;/img&amp;gt;
                &amp;lt;h3&amp;gt;{title}&amp;lt;/h3&amp;gt;
                &amp;lt;p&amp;gt;{description.slice(0, 100)}&amp;lt;Link to={`/product/${id}`}&amp;gt;See more&amp;lt;/Link&amp;gt;&amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
        )
    })

    return (
        &amp;lt;&amp;gt;
            &amp;lt;section className="card-section"&amp;gt;
                {productItems}
            &amp;lt;/section&amp;gt;
        &amp;lt;/&amp;gt;
    );
};

export default Card;

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

&lt;/div&gt;



&lt;p&gt;Note that the value of our &lt;code&gt;to&lt;/code&gt; attributes uses a backtick and template literals ( ${} ) with the value–&lt;code&gt;id&lt;/code&gt;. This is the standard method of accessing the URL path of each parameter.&lt;/p&gt;

&lt;p&gt;Save all your files and navigate to your browser. The gif image below shows the outcome of our project. Each product can now be accessed through its unique ids.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0FIZWDeF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v266esuvfiyjwu2s3mcf.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0FIZWDeF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v266esuvfiyjwu2s3mcf.gif" alt="useparams-gif" width="690" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This document provides a comprehensive knowledge of the useParams hook. The useParams hook is essential in creating React applications that require multiple parameters. Thus, enabling easy access to each parameter in a user-friendly manner.&lt;/p&gt;

&lt;p&gt;Thank you for reading and I hope you find this tutorial useful.&lt;/p&gt;

&lt;p&gt;Additional Resources&lt;/p&gt;

&lt;p&gt;&lt;a href="https://javascript.plainenglish.io/react-router-how-to-use-the-useparams-hook-321a6461732"&gt;React Router: How to Use the useParams() Hook&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://refine.dev/blog/react-router-useparams/"&gt;How to use the useParams hook in React Router&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>programming</category>
      <category>javascript</category>
    </item>
    <item>
      <title>A Beginner's Guide: Understanding CSS Animation</title>
      <dc:creator>Nehemiah Dauda</dc:creator>
      <pubDate>Fri, 04 Aug 2023 23:06:23 +0000</pubDate>
      <link>https://dev.to/meganad60/a-beginners-guide-understanding-css-animation-29l2</link>
      <guid>https://dev.to/meganad60/a-beginners-guide-understanding-css-animation-29l2</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Cascading Style Sheet (CSS)&lt;/strong&gt; is a style sheet language that's used to design, organize, and beautify our web content. CSS styles our documents that are written in a markup language such as HTML–HyperText Markup Language.&lt;/p&gt;

&lt;p&gt;An impressive feature of CSS is that it can be use to creates dynamic and interactive web content. For instance, CSS does the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Indicate an active link.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Renders dynamic styles on mouse hover.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Animate Web content and lots more.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The purpose of this article is on CSS animation. We aim to simplify and communicate the concept of CSS animation. What we shall be looking at in this article includes the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The meaning of CSS Animation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;@keyframe&lt;/code&gt; rules.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Attributes of CSS Animation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The shorthand value of CSS animation.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Prerequisite&lt;/strong&gt;&lt;br&gt;
This article targets beginners and professionals who seek to improve their knowledge of CSS animation. Although you must have a basic understanding of HTML and CSS, as this article does not cover such knowledge. If you're unfamiliar with HTML and CSS, I recommend that you first need to learn and acquaint yourself before moving ahead with this article.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;What is CSS Animation?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;CSS animation is a feature of CSS that enable developers to create interactive and dynamic web content without the use of extra codes such as JavaScript. JavaScript is the popular language used to create interactive and dynamic web content. Nevertheless, CSS animation creates dynamic and animated web content. For instance, CSS animation can do the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Creates web contents/objects on the motion.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Renders different colors and background colors of web content.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Change and update web content styles and lots more.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To implement CSS animation, the &lt;code&gt;@keyframe&lt;/code&gt; rule must be applied. Let's look at what the&lt;code&gt;@keyframe&lt;/code&gt; rule implies.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;What is the &lt;code&gt;@Keyframe&lt;/code&gt; Rule?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;@Keyframe&lt;/code&gt; rule determines the CSS animation codes. Let's say you want to change the background color of an element using CSS animation, the &lt;code&gt;@keyframe&lt;/code&gt; rule is where you'll specify the initial background color and the updated background color. See the example below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@keyframe example{
  from {background-color: red}
  to {background-color: blue}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;@keyframe&lt;/code&gt; rule contains attributes that determine CSS animation. From our above example, the &lt;code&gt;@keyframe&lt;/code&gt; rule contains 2 attributes–' from' and 'to'.&lt;/p&gt;

&lt;p&gt;The 'from' attribute accepts the initial CSS style attributes of your web content to be animated. In our above example, the 'from' attribute contains our initial CSS style attribute e.g. background-color: red.&lt;/p&gt;

&lt;p&gt;The ‘to’ attributes accept the new updated CSS style attributes. In our above codes, the 'to' attribute accepts a new attribute for our background color, which is blue. As a result, our background color changes from red to blue. Impressive right? Let's see more examples.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@keyframe example{
  0% {background-color: red}
  100% {background-color: blue}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In our above codes, we use percentage attributes instead of the "from" and "to" attributes. Using percentage attributes is another way that the &lt;code&gt;@keyframe&lt;/code&gt; rule permits. The percentage attribute starts from 0% and ends at 100%. The 0% accepts the initial CSS style attributes while the 100% accepts the final CSS style attributes.&lt;/p&gt;

&lt;p&gt;One major feature of the &lt;code&gt;@keyframe&lt;/code&gt; rule is that it can take in as many attributes as possible. See the example below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@keyframe example{
  0% {background-color: red}
  50% {background-color: green}
  100% {background-color: blue}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In our above codes, we use the percentage attributes to update our background color up to three times. We can further increase our attributes to as many as possible.&lt;/p&gt;

&lt;p&gt;Take note of the following about the &lt;code&gt;@keyframe&lt;/code&gt; rule:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;An animation name must be specified when using &lt;code&gt;@keyframe&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;@keyframe&lt;/code&gt; keyword must first be declared before your animation name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;@keyframe&lt;/code&gt; rule contains attributes wrapped in between curly braces.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;@keyframe&lt;/code&gt; attributes accept CSS style attributes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The CSS style attributes are also wrapped in between curly braces.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Attributes of CSS Animation&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The attributes of CSS animation are CSS style attributes/properties that help us to animate our web content. For CSS animation to take effect, CSS style attributes such as animation-name, duration, and amongst others, must be specified. Let's study the below codes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/*index.html*/

&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Document&amp;lt;/title&amp;gt;
    &amp;lt;link rel="stylesheet" href="style.css"&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;div class="box"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&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;/*style.css*/

.box{
    width: 100px;
    height: 100px;
    animation-name: example;
    animation-duration: 4s;
}

@keyframe example{
  from {background-color: red}
  to {background-color: blue}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In our above codes, we have two documents–index.html and style.css. The index.html file contains markup language and in between the body tag, we have a div tag with a class property–box.&lt;/p&gt;

&lt;p&gt;Furthermore, in our style.css file, the box class in our index.html file is referenced. The box class contains some CSS style attributes for our animation.&lt;/p&gt;

&lt;p&gt;Therefore, in this section, we shall be looking at CSS style attributes that help us animate our web content.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Animation name&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The animation name is a required attribute of CSS animation. The animation name defines the name of the animation that the &lt;code&gt;@keyframe&lt;/code&gt; rule indicates. See the 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;style.css

.box{
    width: 100px;
    height: 100px;
    animation-name: example;
    animation-duration: 4s;
}

@keyframe example{
  from {background-color: red}
  to {background-color: blue}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In our above codes, we have an animation name (example) set as a style attribute to the box class. Next, the &lt;code&gt;@keyframe&lt;/code&gt; rule indicates our animation name, which then accepts the animation attributes in curly braces.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Animation duration&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The animation duration attribute specifies how long the animation should take place. Note that the default value of animation duration is 0. Hence, if you don't specify the animation duration, the animation will not run. The example below specifies that the animation should run for 4 seconds.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;style.css

.box{
    width: 100px;
    height: 100px;
    animation-name: example;
    animation-duration: 4s;
}

@keyframe example{
  from {background-color: red}
  to {background-color: blue}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Animation Delay&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The animation-delay attribute specifies the duration before the animation should start. The code below specifies that the animation should start after 2 seconds.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;style.css

.box{
    width: 100px;
    height: 100px;
    animation-name: example;
    animation-duration: 4s;
    animation-delay: 2s;
}

@keyframe example{
  from {background-color: red}
  to {background-color: blue}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that when the animation-delay attribute contains a negative value, the animation runs as if it has already started.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Animation direction&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The animation-direction attribute specifies the direction of the animation. An animation-direction attribute contains any of the following values:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;normal&lt;/code&gt;—specifies that the animation will play forward i.e from initial to final attributes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;reverse&lt;/code&gt;—specifies that the animation will play backward i.e from final to initial attributes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;alternate&lt;/code&gt;—specifies that the animation will play forward first, and then backward&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;alternate-reverse&lt;/code&gt;—specifies that animation will play in a backward direction first, and then forward&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The below example shows the animation will play in the backward direction. That is the background color will first appear in blue and start changing from blue to red.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.box{
    width: 100px;
    height: 100px;
    position: relative;
    animation-name: example;
    animation-duration: 4s;
    animation-delay: 2s;
    animation-direction: reverse;
}

@keyframes example{
    0% {background-color: red;}
    50% {background-color: green;}
    100% {background-color: blue;}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Animation iteration count&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The animation iteration count specifies the number of times that the animation will run.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.box{
    width: 100px;
    height: 100px;
    position: relative;
    animation-name: example;
    animation-duration: 4s;
    animation-delay: 0.1s;
    animation-iteration-count: 3;
}

@keyframes example{
    0% {background-color: red; left: 0px;}
    50% {background-color: green; height: 200px; left: 200px;}
    100% {background-color: blue; left: 0px;}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above example runs the animation 3 times. The animation-iteration count also accepts the value of 'infinite', which means that the animation will run forever.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Animation timing function&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The animation-timing function specifies the speed of the animation. In this case, the value of the animation timing function determines how fast and slow the animation runs. The animation-timing-function accepts the following values:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;ease&lt;/code&gt;—specifies that the animation starts slowly, then fast, and then ends slowly. Note that this is the default value of the animation-timing-function&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;linear&lt;/code&gt;—specifies that the animation start and ends at the same speed&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;ease-in&lt;/code&gt;—specifies that the animation speed starts slowly and ends so fast&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;ease-out&lt;/code&gt;—specifies that the animation speed starts so fast and ends slowly&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;ease-in-out&lt;/code&gt;—specifies that the animation speed start and end slowly&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;cubic-bezier()&lt;/code&gt;—allows you to customize the animation speed. Note that the cubic-bezier() function accepts 4 parameters in numbers, separated by a comma.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Below is an example of using the animation-timing-function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.box{
    width: 100px;
    height: 100px;
    position: relative;
    background-color: red;
    animation-name: example;
    animation-duration: 4s;
    animation-delay: 0.1s;
    animation-direction: reverse;
    animation-iteration-count: 3;
    animation-timing-function: ease-in;
}

@keyframes example{
    0% {background-color: red; left: 0px;}
    50% {background-color: green; left: 200px;}
    100% {background-color: blue; left: 0px;}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Animation fill mode&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The animation fill mode specifies the CSS styles for the element before the animation starts and after it has ended. Below are values that the animation-fill-mode attributes accept.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;none&lt;/code&gt;—the animation element will not apply any CSS style before and after execution.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;forwards&lt;/code&gt;—the animation element retains the CSS style set by the final keyframe attributes when the animation stops execution. Although the final keyframe attributes depend on the animation direction and the animation iteration count.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;backwards&lt;/code&gt;—the animation element retains the initial CSS style set by the first keyframe attributes before execution. Although the First keyframe attributes depend on the animation direction and the animation iteration count.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;both&lt;/code&gt;—the animation element retains the initial CSS styles before execution and likewise retains the final CSS styles after execution. In other words, the animation follows the rules for both the forwards and the backwards value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;initial&lt;/code&gt;—the animation element retains the initial CSS style before the animation executes and when the animation stops execution.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;inherit&lt;/code&gt;—the animation element inherits the CSS style from the parent element styles before the animation executes and when the animation stops execution.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Below is an example of using the animation-fill-mode.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.box{
    width: 100px;
    height: 100px;
    position: relative;
    background-color: yellow;
    animation-name: example;
    animation-duration: 4s;
    animation-delay: 1s;
    animation-direction: reverse;
    animation-iteration-count: 1;
    animation-timing-function: ease-in;
    animation-fill-mode: forwards;
}

@keyframes example{
    0% {background-color: red; left: 0px;}
    50% {background-color: blue; left: 200px;}
    100% {background-color: green; left: 0px;}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;CSS Animation Shorthand Property&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The CSS animation shorthand property enables us to write our CSS animation style attributes with just one line of code. The examples below indicate CSS animation with and without shorthand properties.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/*example 1*/

.box{
    width: 100px;
    height: 100px;
    position: relative;
    background-color: yellow;
    animation-name: example;
    animation-duration: 4s;
    animation-timing-function: ease-in;
    animation-delay: 1s;
    animation-iteration-count: infinite;
    animation-direction: reverse;
}
&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;/*example 2*/

.box{
    width: 100px;
    height: 100px;
    position: relative;
    background-color: yellow;
    animation: example 4s ease-in 1s infinite reverse;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above examples both work the same. Although the second example uses CSS animation shorthand property, hence, has shorter codes than the first example.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;CSS animation is a great way to create dynamic and interactive web content without the use of JavaScript codes. This article explains all you need to know to implement CSS animation. For instance, this article explains basic concepts such as the &lt;code&gt;@keyframe&lt;/code&gt; rule and attributes of CSS animation.&lt;/p&gt;

&lt;p&gt;For you to perfect your skills in CSS animation, I recommend that you should read this article thoroughly and practice regularly.&lt;/p&gt;

&lt;p&gt;Congratulations on adding another new CSS skill. Hope you find this article interesting. If yes, follow me on &lt;a href="https://twitter.com/dauda_nehemiah"&gt;Twitter&lt;/a&gt; and &lt;a href="https://www.linkedin.com/in/nehemiah-dauda"&gt;LinkedIn&lt;/a&gt; as I share more insightful and educational technical content.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>A Beginner's Guide: Essentials of React</title>
      <dc:creator>Nehemiah Dauda</dc:creator>
      <pubDate>Sat, 29 Jul 2023 23:46:51 +0000</pubDate>
      <link>https://dev.to/meganad60/a-beginners-guide-essentials-of-react-3lb0</link>
      <guid>https://dev.to/meganad60/a-beginners-guide-essentials-of-react-3lb0</guid>
      <description>&lt;p&gt;React is one of the most widely used JavaScript libraries in developing User Interfaces (UI). React offers several features and benefits that make it stand out in the software development industry. To be a Good React Developer, it is important to know the essentials of React.&lt;/p&gt;

&lt;p&gt;The goal of this article is to educate on the fundamentals of React. We shall be looking at the following important topics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What is React?&lt;/li&gt;
&lt;li&gt;Evolution of React.&lt;/li&gt;
&lt;li&gt;Structure of React.&lt;/li&gt;
&lt;li&gt;Feature of React.&lt;/li&gt;
&lt;li&gt;Benefits of React.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ready to learn? Let's get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is React?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;React is a JavaScript library used in developing interactive user interfaces. React can also be used to develop &lt;strong&gt;Single Page Applications (SPAs)&lt;/strong&gt;, hence, increasing app performance.&lt;/p&gt;

&lt;p&gt;Initially developed to serve as a frontend JavaScript library, React has over the years evolved and can now be used to develop server-side rendering as well as mobile applications. For instance, React Native is used to develop iOS and Android mobile apps.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Evolution of React&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Jordan Walke—a software engineer at Facebook now known as Meta—developed React. Jordan Walke initially created a prototype called 'FaxJS'. FaxJS was first deployed to Facebook News Feed in 2011. In 2012, Facebook acquired Instagram and later on, deployed FaxJS to Instagram.&lt;/p&gt;

&lt;p&gt;On May 2013, React was officially launched and it became open-source at the JSConf in the US. Maintained by Facebook (now Meta), React is used to create interactive web interfaces.&lt;/p&gt;

&lt;p&gt;On February 2015, at the React Conference, Facebook announced the creation of React Native, which later became open-source in March 2015. React Native is used in developing iOS and Android applications.&lt;/p&gt;

&lt;p&gt;On April 18, 2017, Facebook announced a new set of algorithms for rendering known as React Fiber. This innovation improves on the former algorithms known as 'Stack'. The Stack was slow in rendering dynamic changes. Meanwhile, with Fibers, the structure of the page is broken into segments that make it easy to maintain and update independently.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Structure of React&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this section, we shall be looking at the structural composition of React. We'll follow the officially recommended process of creating React app ready for development. Let's get started.&lt;/p&gt;

&lt;p&gt;The official doc of React recommended using Create React App when learning React or creating a new single-page app. Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; C:\Users\Username\Desktop\project_folder&amp;gt;npx create-react-app my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After you've created your react app, your project should look like the below file structure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my-app/
    node_modules/
    public/
        favicon.ico
        index.html
    src/
        App.css
        App.js
        App.test.js
        index.css
        index.js
        logo.svg
    .gitignore
    package.json
    README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let's explore the above files and folders and know their uses.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;node_modules folder&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This folder contains all packages and dependencies that your project required. As you install these dependencies and packages, they are downloaded and copied into the node_modules folder. Note that it is recommended not to commit this folder to your version-controlled repository as it is too large.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;public folder&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The public folder contains the index.html file where you can set your page title and meta tags. You can add other assets in the public folder such as stylesheets, scripts, images, and fonts.&lt;/p&gt;

&lt;p&gt;Take note of the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Webpack does not process the public folder.&lt;/li&gt;
&lt;li&gt;Use an environment variable called &lt;code&gt;PUBLIC_URL&lt;/code&gt; to reference assets in the public folder. For instance, use it like this in your index.html file:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;link rel="icon" href="%PUBLIC_URL%/favicon.ico /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;src folder&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The src folder contains files that are processed by Webpack—a JavaScript tool commonly used by React to bundle and manage dependencies. All JavaScript files and CSS files must be inside the src folder for Webpack to see and process them.&lt;/p&gt;

&lt;p&gt;Default files in the src folder include App.js, App.css, App.test.js, index.js, index.css, and so on. This folder is where you can also create components. Let's explore some of the default files.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;App.js—the root component that contains contents to be rendered. Although App.js can be replaced or renamed.&lt;/li&gt;
&lt;li&gt;App.css—the file that contains styles for the App.js component.&lt;/li&gt;
&lt;li&gt;App.test.js—the default file where you can conduct basic tests for your app.&lt;/li&gt;
&lt;li&gt;index.js—a JavaScript file that renders our main component.&lt;/li&gt;
&lt;li&gt;index.css—the file that contains general styles for your project.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note that index.html in the public folder and index.js in the src folder, must not be changed for the project to build. They must exist with their exact file names&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;.gitignore file&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The .gitignore file specifies folders and files that Git should ignore and keep untracked.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;package.json&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This file contains in JSON format, important information about your project. The below lists are some of the important information in the package.json file:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;name&lt;/code&gt;—the name of your project. It must be less than or equal to 214 characters&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;version&lt;/code&gt;—the current version of your app&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;dependencies&lt;/code&gt;—sets of packages and their version&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;scripts&lt;/code&gt;—sets of node commands we can run.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Readme.md&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This is a markdown file that contains the project summary and instructions.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Features of React&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;React is made up of amazing and unique features. These features are what made React to be popular, easy to read, and maintain. Let's examine some of the major features of React.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Components&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Components are pieces of independent and reusable codes used to create user interfaces. Components are JavaScript functions that return HTML elements. Components make it easy to read and maintain React codes. They also enable fewer codes to be written as they are reusable i.e. can be used in several parts of the application. App.js is an example of a component. See the image below.&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%2Fhmuqhxx2nwfpqxrcghc5.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%2Fhmuqhxx2nwfpqxrcghc5.png" alt="App.js component"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;JavaScript Syntax Extension&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;JavaScript Syntax Extension (JSX)&lt;/strong&gt; also refers to the JavaScript XML is a JavaScript feature that allows us to write HTML elements in JavaScript codes. The below codes is an example of JSX.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const = listItems =  {
    &amp;lt;ul className="listItems"&amp;gt;
        &amp;lt;li&amp;gt;Item 1&amp;lt;/li&amp;gt;
        &amp;lt;li&amp;gt;Item 2&amp;lt;/li&amp;gt;
        &amp;lt;li&amp;gt;Item 3&amp;lt;/li&amp;gt;
        &amp;lt;li&amp;gt;Item 4&amp;lt;/li&amp;gt;
    &amp;lt;/ul&amp;gt;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Babel library—a JavaScript compiler—transforms the HTML elements into plain JavaScript. The significance of JSX is that it simplifies JavaScript codes making them easy to read, especially for someone familiar with HTML.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Props&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Props in React stand for properties. They are arguments passed into React components just as HTML attributes.&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;img src="./image.jpg" width="100" height="150"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code is an HTML image tag that contains some attributes–src, width, and height. These attributes determined how the image is rendered. The same goes for Props. They are functional arguments passed to components. Props are read-only as they can't be modified. Let's see a simple example of props.&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;Car brand="Toyota"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code, the Car element has an attribute–brand.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Function Car(props){
    return(
        &amp;lt;h1&amp;gt;The Car brand is {props.name}&amp;lt;/h1&amp;gt;
    )
}

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

&lt;/div&gt;



&lt;p&gt;Next, to render our attribute, the Car component receives an argument–props—which can be any name of your choice—as seen in the codes above.&lt;/p&gt;

&lt;p&gt;In essence, props store data that is accessed by children of React component.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;States&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;States in React, are objects that store data or information about the component. Unlike props, states are mutable—they can be modified upon user request. When a state is modified, React re-renders the component on the browser. Let's see an example of a state.&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";

class Car extends React.Component{
    constructor(props){
        super(props);
        this.state = {
            brand: "Toyota",
            model: "Mustang",
            color: "Red",
            year: "1964"
        };
    }

    changeBrand = () =&amp;gt; {
        this.setState({brand: "Honda"})
    }
    render(){
        return(
            &amp;lt;div&amp;gt;
                &amp;lt;p&amp;gt;The Car brand is {this.state.brand}&amp;lt;/p&amp;gt;
                &amp;lt;button onClick={this.changeBrand}&amp;gt;Click&amp;lt;/button&amp;gt;
            &amp;lt;/div&amp;gt;
        );
    }
}

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

&lt;/div&gt;



&lt;p&gt;The above codes display the screenshot below&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%2Fh1gus6ht0v5ewg4bg5dj.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%2Fh1gus6ht0v5ewg4bg5dj.png" alt="state"&gt;&lt;/a&gt;&lt;br&gt;
When a user clicks the button, Toyota gets updated to Honda as indicated in the codes.&lt;/p&gt;

&lt;p&gt;Take note of the following about states:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The State object can store many properties as you like.&lt;/li&gt;
&lt;li&gt;The State objects are mutable i.e. they can be modified based on user request.&lt;/li&gt;
&lt;li&gt;The setState method is used to change the state object.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;React hooks&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Hooks are functions that give access to states and other React features. With React hooks, class components are not needed.&lt;/p&gt;

&lt;p&gt;Hooks are a new addition to React in version 16.8. Let's examine some of these React hooks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;useState Hook&lt;/strong&gt;&lt;br&gt;
This is functional hooks that keep track of a state. The useState hook accepts an initial value and gets updated upon user request.&lt;br&gt;
&lt;/p&gt;

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

function App(){

    const [count, setCount] = useState(0);

    const handleClick = () =&amp;gt; {
        setCount(count + 1)
    }

    return (
        &amp;lt;&amp;gt;
            &amp;lt;p&amp;gt;You click me {count} times&amp;lt;/p&amp;gt;
            &amp;lt;button onClick={handleClick}&amp;gt;Click me&amp;lt;/button&amp;gt;
        &amp;lt;/&amp;gt;
    )
}

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

&lt;/div&gt;



&lt;p&gt;The above code displays the screenshot below&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%2Ff9lv2oxd225u8q41v2dl.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%2Ff9lv2oxd225u8q41v2dl.png" alt="useState hook"&gt;&lt;/a&gt;&lt;br&gt;
This example of useState hook accepts an initial value–0, and it increases the value when a user clicked the button.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;useEffect hook&lt;/strong&gt;&lt;br&gt;
The useEffect hook performs side effects such as fetching data from a backend server, updating the DOM, timers, and so on. The useEffect hook accepts two arguments–function and dependency. Although the second argument is optional.&lt;br&gt;
&lt;/p&gt;

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

useEffect(() =&amp;gt; {
// Runs after every rendering
}, [])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above is an example of a useEffect hook structure with a dependency as an empty array.&lt;/p&gt;

&lt;p&gt;Other React hooks include&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;useContext&lt;/li&gt;
&lt;li&gt;useRef&lt;/li&gt;
&lt;li&gt;useReducer&lt;/li&gt;
&lt;li&gt;useCallback&lt;/li&gt;
&lt;li&gt;useMemo&lt;/li&gt;
&lt;li&gt;Custom Hooks.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Benefits of React&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The benefit of React is enormous, as it served several purposes. Let's examine some of the benefits.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Web app development:&lt;/strong&gt; React can be used to develop websites with backend servers, using React frameworks. Some of these frameworks include Next.js, Gatsby, Remix, and amongst others.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mobile app development:&lt;/strong&gt; React can be used to develop mobile applications–iOS and Android mobile apps–using React Native.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Single Page Applications:&lt;/strong&gt; React can be used to create SPAs. SPAs render dynamic content on a single page, which reduces loading time and increases performance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Highly demanded:&lt;/strong&gt; React is the most widely used JavaScript library in developing interactive user interfaces. Hence, the high demand for React developers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Easy maintainability:&lt;/strong&gt; React apps are developed using independent components. These components serve as JavaScript functions but work in isolation and return HTML elements. As a result, making React easy to read and maintained.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reusability:&lt;/strong&gt; React components are reusable. In other words, React components can be used in several parts of the applications, thereby reducing the amount of code to be written and enabling quick development.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In summary, this article has helped us to understand the essentials of React. It is important to know the fundamentals of React so as to build a solid foundation in becoming a professional React developer. In this article, we looked at what React entails, its history, structure, features, and finally, the benefits of React. It's not over yet, explore in-depth of React with more practice and grow your expertise and experience.&lt;/p&gt;

&lt;p&gt;If you find this article useful, hit the like button and follow me on &lt;a href="https://twitter.com/dauda_nehemiah" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; and &lt;a href="https://www.linkedin.com/in/nehemiah-dauda" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; for more insightful and progressive tech conversation.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Quick Guide To Set Up Your React App Ready For Development.</title>
      <dc:creator>Nehemiah Dauda</dc:creator>
      <pubDate>Fri, 28 Jul 2023 15:04:09 +0000</pubDate>
      <link>https://dev.to/meganad60/quick-guide-to-set-up-your-react-app-ready-for-development-1hm9</link>
      <guid>https://dev.to/meganad60/quick-guide-to-set-up-your-react-app-ready-for-development-1hm9</guid>
      <description>&lt;p&gt;React is one of the most widely used JavaScript libraries in creating software interfaces. React offers several tools that make it stand out and popular in today’s software development industry. Thus, it's a great feat to be a React developer. The purpose of this article is to provide a quick guide in creating your first React app and setting it ready for development.&lt;/p&gt;

&lt;p&gt;Before we set up our first React app, let’s know what React entails and its benefits. This will give us a thorough insight into React as we journey through this career in becoming a React developer. Let’s get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is React?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;React is a JavaScript library used in developing interactive and robust User Interfaces (UI). In other words, React is used to create front-end web applications. React can be used to develop Single Page Applications (SPAs) using independent and reusable components, thereby increasing her readability and maintainability.&lt;/p&gt;

&lt;p&gt;Jordan Walke — a software engineer at Facebook now known as Meta — developed React. Jordan Walke first came up with a prototype known as FaxJS. FaxJS was initially deployed to the Facebook News feed in 2011. On May 2013, React was officially launched and made an open-source at the JavaScript Conference in the US.&lt;/p&gt;

&lt;p&gt;Over the years, React has evolved to include several features which serve as frameworks for developing complete applications. Some of these frameworks include Next.js, Gatsby, and React Native, amongst others. Next.js and Gatsby.js frameworks develop backend servers of web applications. React Native is used to develop mobile applications such as iOS and Android mobile apps.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Benefits of React&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;React is the most widely used JavaScript library. This is because of the benefits React offers. In this section, we shall examine the notable benefits of React. Let’s get started.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Web App Development:&lt;/strong&gt; React-powered frameworks are used to develop full Web applications. For instance, React-powered frameworks provide features for server-side rendering, data fetching, routing and so on. These frameworks are maintained by various communities, which include Next.js maintained by Vercel, Gatsby maintained by Netlify, and Remix maintained by Shopify, amongst others.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mobile App Development:&lt;/strong&gt; React Native — a React-powered framework — is used to develop mobile applications. React Native is an open-source JavaScript Framework that is used to develop iOS and Android mobile apps.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Easy Maintainability:&lt;/strong&gt; React applications are developed using components. These components are independent and reusable. In other words, these components work separately and can be used in several parts of the application. Thus, increases the readability and maintainability of React codes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reusability:&lt;/strong&gt; React components are independent pieces of code. These components work separately and can be used in various parts of the application. Thus, reduces the amount of code to be written and ensures the effectiveness of the application.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Testing and Debugging:&lt;/strong&gt; React provides developers with tools to test and debug their codes and ensure the effectiveness and efficiency of their software. Some such tool includes Jest, React Developer Tools, and so on. Developers can test and debug their codes with ease and ensure they work correctly as expected.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Steps In Setting Up React Applications&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This section will guide you through the steps in creating your first React app ready for development. Note that we shall be using the officially recommended process of creating a React app. Let’s get started with the various steps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1 — Install Node.js&lt;/strong&gt;&lt;br&gt;
You need to install Node.js for the local development of your React app. To install Node.js, visit &lt;a href="https://nodejs.org"&gt;https://nodejs.org&lt;/a&gt; and follow the instructions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;STEP 2 — Create a Project folder&lt;/strong&gt;&lt;br&gt;
Create a project folder and navigate to the directory of your project folder using your terminal as seen in the 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;C:\Users\Usersname\Desktop&amp;gt;mkdir react_project
C:\Users\Usersname\Desktop&amp;gt;cd react_project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;STEP 3 — Create React App&lt;/strong&gt;&lt;br&gt;
Create your new React app by typing any of the commands below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\Usersname\Desktop\react_project&amp;gt;npx create-react-app my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OR&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\Usersname\Desktop\react_project&amp;gt;npm init react-app my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For yarn users, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\Usersname\Desktop\react_project&amp;gt;yarn create-react-app my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The installation process takes a while to complete. When completed, a folder named ‘my-app’ will be created, containing several files and folders just like the below structure. Note that ‘my-app’ is the name of your React app and can be any name of your choice.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my-app/
    node_modules/
    public/
        favicon.ico
        index.html
    src/
        App.css
        App.js
        App.test.js
        index.css
        index.js
        logo.svg
    .gitignore
    package.json
    README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;STEP 4 — Start the server&lt;/strong&gt;&lt;br&gt;
In your terminal, navigate to the app directory where package.json is located. The package.json file contains scripts that give you access to run React script commands such as start, build, test, etc. Start the development server as seen in the 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;C:\Users\Usersname\Desktop\react_project\my-app&amp;gt;npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above command starts the development server and opens your default browser. The development server is run on localhost:3000, with the image below displayed on your screen.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--J3OPJqwV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k7az5pefeg7617wbmfng.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J3OPJqwV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k7az5pefeg7617wbmfng.png" alt="React homepage" width="800" height="389"&gt;&lt;/a&gt;&lt;br&gt;
An impressive feature of React development server is the &lt;strong&gt;Hot Module Replacement (HMR)&lt;/strong&gt;. The HMR updates the web page without reloading when a component is modified.&lt;/p&gt;

&lt;p&gt;In conclusion, we’ve understood what React entails and how important it is in the software development industry. we’ve also achieved a great step in setting up a React app ready for development. Congratulations on our progress. Explore other tools and functionalities in React to grow and perfect your skills as a React developer.&lt;/p&gt;

&lt;p&gt;I hope you find this article useful. Follow me on &lt;a href="https://twitter.com/dauda_nehemiah"&gt;Twitter&lt;/a&gt; and &lt;a href="https://www.linkedin.com/in/nehemiah-dauda"&gt;LinkedIn&lt;/a&gt; as we share insightful and innovative ideas.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>React Routing: Practical Steps in Creating Navigation Bar that Renders Dynamic Content with React.</title>
      <dc:creator>Nehemiah Dauda</dc:creator>
      <pubDate>Wed, 26 Jul 2023 23:08:18 +0000</pubDate>
      <link>https://dev.to/meganad60/react-routing-practical-steps-in-creating-navigation-bar-that-renders-dynamic-content-with-react-2jon</link>
      <guid>https://dev.to/meganad60/react-routing-practical-steps-in-creating-navigation-bar-that-renders-dynamic-content-with-react-2jon</guid>
      <description>&lt;p&gt;A newbie in React will find it challenging in creating a navigation bar that renders different contents. Notable for building &lt;strong&gt;Single Page Applications (SPAs)&lt;/strong&gt;, React does not provide any modalities for routing. Nevertheless, routing in React is done using an external library known as React-router-dom. What this article aims to achieve is to create a Navigation bar with React. This Navigation bar will enable Users to navigate between internal links and renders different content.&lt;/p&gt;

&lt;p&gt;To get a better understanding as we create our Navigation bar, this article will explain the following concepts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React&lt;/li&gt;
&lt;li&gt;SPAs&lt;/li&gt;
&lt;li&gt;React Router Dom&lt;/li&gt;
&lt;li&gt;Routing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is React?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;React also known as ReactJS is a JavaScript library used in building interactive and dynamic web interfaces. In other words, React builds the front end of web pages that interacts with Users.&lt;/p&gt;

&lt;p&gt;Although React was created as a Frontend library, over the years, React has evolved and can now be used to build complete applications. In general, React can be used to develop the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Single Page Applications (SPAs)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Backend server using frameworks such as Next.js, Gatsby.js, and so on&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mobile applications using React Native.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What are Single Page Applications (SPAs)?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;SPAs are websites that render different content based on user requests without loading a new page. For instance, the default website loads an entirely new page when a user clicks a navigation link leading to other pages of the website. SPAs work in contrast to the default websites. SPAs load different web content on a single static page.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What Is React-router?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;React-router is an external library that enables React apps to navigate between links and render different contents based on user requests. React router must be installed before it can be used in React.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What Is Routing?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Routing is the act of navigating to different sites, contents or pages using links based on user request. Through routing, a user can access different content on the websites.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Practical Steps in Creating Navigation Bar that Renders Dynamic Content.&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this section, we shall be building a React navigation bar that contains links rendering different contents based on user requests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; To create a React app using React official doc recommendation, you must install Node.js and NPM on your computer. Visit &lt;a href="https://nodejs.org" rel="noopener noreferrer"&gt;https://nodejs.org&lt;/a&gt; to download Node.js and NPM if you don't have them on your computer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisite:&lt;/strong&gt; To have the best out of this article, it is important to be knowledgeable in JavaScript and React library tools such as Object, Object destructuring, JSX, Components, and Variables, amongst others. If you are unfamiliar with the above tools, I recommend taking some time to learn and get familiar with them. Ready to learn? Let's get started.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1 - Create A React App.&lt;/strong&gt;&lt;br&gt;
Follow the below instructions to create a React app:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create a folder for your React project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigate to the directory of the folder on your terminal to create a react app.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use npx or npm or yarn to create your react app as seen in the codes below.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\Username\Desktop&amp;gt;mkdir react-app
C:\Users\Username\Desktop&amp;gt;cd react-app
C:\Users\Username\Desktop\react-app&amp;gt;npx create-react-app my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;OR&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\Username\Desktop\react-app&amp;gt;npm init react-app my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OR&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\Username\Desktop\react-app&amp;gt;Yarn create-react-app my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Take note of the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;react-app&lt;/code&gt; is the folder name and it can be any name of your choice.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;my-app&lt;/code&gt; is the name of your React app and it can be any name of your choice.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 2 - Install react-router-dom and run the Server.&lt;/strong&gt;&lt;br&gt;
Follow the below instructions to install react-router-dom and run the sever.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to your React app directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install react-router-dom using npm.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Start the server using npm after react-router-dom has finished installing.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;See the 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;C:\Users\Username\Desktop\react-app&amp;gt;cd my-app
C:\Users\Username\Desktop\react-app\my-app&amp;gt;npm install react-router-dom
C:\Users\Username\Desktop\react-app\my-app&amp;gt;npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The development server runs some scripts and then your default browser opens on localhost:3000 and displays the image below.&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%2Falpbufs65bpd9g78cddw.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%2Falpbufs65bpd9g78cddw.png" alt="React Homepage"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3 - Modify Index.js File.&lt;/strong&gt;&lt;br&gt;
In this step, we shall begin coding our program as we have already created our app with all necessary installations. The below instructions guide us to modify the index.js file.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open your project folder with any code editor of your choice.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open the index.js file in your src directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Import &lt;code&gt;BrowserRouter&lt;/code&gt; from &lt;code&gt;react-router-dom&lt;/code&gt; using object destructuring.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Update root const by wrapping the app component in between BrowserRouter tags.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Our final codes will look just as in the example below.&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 ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import { BrowserRouter } from 'react-router-dom';

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  &amp;lt;BrowserRouter&amp;gt;
    &amp;lt;App /&amp;gt;
  &amp;lt;/BrowserRouter&amp;gt;
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4 - Create Pages.&lt;/strong&gt;&lt;br&gt;
In this step, we shall be creating different pages with different contents. The following instructions guide us to create the necessary pages:&lt;/p&gt;

&lt;p&gt;Firstly, Create a folder called pages in the src directory with the following files:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Home.js&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;About.js&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Contact.js.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next, Fill each of these files with their dynamic contents as seen below.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Home.js
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Home(){

    return (
        &amp;lt;&amp;gt;
          &amp;lt;h1&amp;gt;Home Page&amp;lt;/h1&amp;gt;
        &amp;lt;/&amp;gt;
    );
}

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

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;About.js
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function About(){

    return (
        &amp;lt;&amp;gt;
          &amp;lt;h1&amp;gt;About Page&amp;lt;/h1&amp;gt;
        &amp;lt;/&amp;gt;
    );
}

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

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Contact.js
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Contact(){

    return (
        &amp;lt;&amp;gt;
          &amp;lt;h1&amp;gt;Contact Page&amp;lt;/h1&amp;gt;
        &amp;lt;/&amp;gt;
    );
}

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

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Step 5 - Create a Navigation Component.&lt;/strong&gt;&lt;br&gt;
Next, we shall be creating a navigation component. Follow the below instructions.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create a folder called 'components' in the src directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a Nav.js file in the components' directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open Nav.js file you just created and import the &lt;code&gt;Link&lt;/code&gt; from &lt;code&gt;react-router-dom&lt;/code&gt; using object destructuring.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a Nav function that returns a nav element with a class–nav.&lt;br&gt;
See the codes below.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Link } from "react-router-dom";

function Nav(){
    return (
        &amp;lt;&amp;gt;
          &amp;lt;nav className="nav"&amp;gt;
            &amp;lt;Link to="/"&amp;gt;Home&amp;lt;/Link&amp;gt;
            &amp;lt;Link to="/about"&amp;gt;About&amp;lt;/Link&amp;gt;
            &amp;lt;Link to="/contact"&amp;gt;Book&amp;lt;/Link&amp;gt;
          &amp;lt;/nav&amp;gt;
        &amp;lt;/&amp;gt;
    );
}

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

&lt;/div&gt;


&lt;p&gt;In our above codes, in between nav tags, we have three Link elements. The Link elements will display as links on our browser and will be used to navigate between pages. The Link opening tags accept a 'to' attribute that points to the resources it's linking to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6 - Modify the App.js file.&lt;/strong&gt;&lt;br&gt;
Open the App.js file in the src directory and execute the following instructions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Import all pages files from the pages folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Import the Nav component from the components folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Import Routes and Route from react-router-dom using object destructuring.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Render the Nav component at the return method of the App function.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a Routes element containing three Route elements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Input each Route element with a path and element attributes.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Our final codes should be like the example below.&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 './App.css';
import Home from './pages/Home';
import About from './pages/About';
import Contact from './pages/Contact';
import Nav from './components/Nav';
import { Routes, Route } from 'react-router-dom';

function App() {
  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;Nav /&amp;gt;

      &amp;lt;Routes&amp;gt;
        &amp;lt;Route path='/' element={&amp;lt;Home /&amp;gt;}&amp;gt;&amp;lt;/Route&amp;gt;
        &amp;lt;Route path='/about' element={&amp;lt;About /&amp;gt;}&amp;gt;&amp;lt;/Route&amp;gt;
        &amp;lt;Route path='/contact' element={&amp;lt;Contact /&amp;gt;}&amp;gt;&amp;lt;/Route&amp;gt;
      &amp;lt;/Routes&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

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

&lt;/div&gt;



&lt;p&gt;In our above codes, the path attributes indicate the URL route. The forward slash of the Home component signifies the default route. The element attributes accept the components to be rendered, which we imported earlier.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7 - Style the Navigation bar.&lt;/strong&gt;&lt;br&gt;
Add CSS styles to our nav component. This can be done in the index.css file. See the 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;.navbar{
  background-color: rgb(14, 136, 207);
  padding: 3px;
  display: flex;
  justify-content: center;
  gap: 20px;
}

.navbar a{
  text-decoration: none;
  color: white;
  font-size: 1.3rem;
}

.navbar a:hover{
  color: aqua;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; we use the 'a' element selector when styling our Link element. This is because Link elements are anchor tags but with slightly different functionality.&lt;/p&gt;

&lt;p&gt;Save your codes and navigate to your browser. Just as in the video below, we can now navigate between links and render different content.&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%2Fyctw75a1d1ab5yr7pzxo.gif" 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%2Fyctw75a1d1ab5yr7pzxo.gif" alt="outcome image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In conclusion, we've created a React app with a navigation bar that enables us to navigate between links. All thanks to React-router-dom. This is not the end, there are many more uses of React-router-dom. Explore more about React-router-dom and gain more experience using it.&lt;/p&gt;

&lt;p&gt;I hope this article was helpful, if yes, hit the like button and follow me on &lt;a href="https://twitter.com/dauda_nehemiah" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; and &lt;a href="https://www.linkedin.com/in/nehemiah-dauda" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; for more insightful tutorials and technical articles.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
