<?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>Forem: Vivek</title>
    <description>The latest articles on Forem by Vivek (@vivek_44751fc408644cbd80b).</description>
    <link>https://forem.com/vivek_44751fc408644cbd80b</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%2F1521794%2Fc6647224-e09f-428a-a122-07d1845bef6d.png</url>
      <title>Forem: Vivek</title>
      <link>https://forem.com/vivek_44751fc408644cbd80b</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/vivek_44751fc408644cbd80b"/>
    <language>en</language>
    <item>
      <title>UseRouter import from next/navigation or next/router in App Router Next JS?</title>
      <dc:creator>Vivek</dc:creator>
      <pubDate>Fri, 24 May 2024 16:02:04 +0000</pubDate>
      <link>https://forem.com/vivek_44751fc408644cbd80b/userouter-import-from-nextnavigation-or-nextrouter-in-app-router-next-js-2pne</link>
      <guid>https://forem.com/vivek_44751fc408644cbd80b/userouter-import-from-nextnavigation-or-nextrouter-in-app-router-next-js-2pne</guid>
      <description>&lt;p&gt;Hi devs, in this article we will learn which solution is better for us.&lt;br&gt;
So many developers facing issue while using useRouter in next JS.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useRouter } from "next/router";

 const router = useRouter();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above import is not working in next JS when we are using app router.&lt;/p&gt;

&lt;p&gt;So as documentation next js allow useRouter from next/navigation in App Router.&lt;br&gt;
Here is the way of importing the useRouter in App Router.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useRouter } from "next/navigation";

  const router = useRouter();

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

&lt;/div&gt;



&lt;p&gt;Thank you for reading. That’s all for today.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>nextjs</category>
      <category>userouter</category>
      <category>react</category>
    </item>
    <item>
      <title>How to Use the &lt;select&gt; Tag with Multiple Values Using the map Method in React.js</title>
      <dc:creator>Vivek</dc:creator>
      <pubDate>Thu, 23 May 2024 21:17:30 +0000</pubDate>
      <link>https://forem.com/vivek_44751fc408644cbd80b/how-to-use-the-tag-with-multiple-values-using-the-map-method-in-reactjs-59df</link>
      <guid>https://forem.com/vivek_44751fc408644cbd80b/how-to-use-the-tag-with-multiple-values-using-the-map-method-in-reactjs-59df</guid>
      <description>&lt;p&gt;Hi Devs, in this article, I’m going to show you how to use the Select HTML tag in React JS. As you all know, we use JSX to write HTML in React. Let’s see how we can do this.&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%2Fdjc1vnobc08aujr5rugo.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%2Fdjc1vnobc08aujr5rugo.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now, we have an array containing the names of cities. So we render this in Web Page using a map method.&lt;/li&gt;
&lt;/ol&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%2Foj988rzdsbmr2e1p41x2.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%2Foj988rzdsbmr2e1p41x2.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;This is a simple method for using the HTML Select tag. However, we won’t be using this method as it’s considered old school. Instead, we are going to use the Map method.&lt;/li&gt;
&lt;/ol&gt;

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

    &amp;lt;select name="cities" id="cities"&amp;gt;
            &amp;lt;option value="New York"&amp;gt;New York&amp;lt;/option&amp;gt;
            &amp;lt;option value="Chicago"&amp;gt;Chicago&amp;lt;/option&amp;gt;

            &amp;lt;option value="Chicago"&amp;gt;Los Angeles&amp;lt;/option&amp;gt;
          &amp;lt;/select&amp;gt;


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

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;The map method in JSX is used to iterate over an array and render a list of elements dynamically.&lt;/li&gt;
&lt;/ol&gt;

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

      &amp;lt;select name="cities" id="cities" &amp;gt;
            {cities.map((ele, key) =&amp;gt; (
              &amp;lt;option value={ele} key={key}&amp;gt;
                {ele}
              &amp;lt;/option&amp;gt;
            ))}
          &amp;lt;/select&amp;gt;


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

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;In this final step, we will see how to get the current element in an Select tag using the onChange method. The onChange event is triggered when the value of an input element, like a text field or dropdown, changes. It allows you to capture and respond to the new value.&lt;/li&gt;
&lt;/ol&gt;

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


  const cities = ["New York", "Los Angeles", "Chicago"]

  const handleChange =(e)=&amp;gt;{
    console.log(e.target.value)
  }

&amp;lt;select name="cities" id="cities" onChange={(e)=&amp;gt;handleChange(e)} &amp;gt;
            {cities.map((ele, key) =&amp;gt; (
              &amp;lt;option value={ele} key={key}&amp;gt;
                {ele}
              &amp;lt;/option&amp;gt;
            ))}
          &amp;lt;/select&amp;gt;


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

&lt;/div&gt;

&lt;p&gt;Thank you for reading this article. please follow for more articles.&lt;/p&gt;

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