<?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: ivadam00</title>
    <description>The latest articles on DEV Community by ivadam00 (@ivadam00).</description>
    <link>https://dev.to/ivadam00</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%2F929478%2F015fb1a3-e67a-494c-89b7-397bfda42e5c.png</url>
      <title>DEV Community: ivadam00</title>
      <link>https://dev.to/ivadam00</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ivadam00"/>
    <language>en</language>
    <item>
      <title>I have a question .</title>
      <dc:creator>ivadam00</dc:creator>
      <pubDate>Fri, 17 Mar 2023 14:35:28 +0000</pubDate>
      <link>https://dev.to/ivadam00/i-have-a-question--2kah</link>
      <guid>https://dev.to/ivadam00/i-have-a-question--2kah</guid>
      <description>&lt;p&gt;how do i change or remove state value when i click to a link or navigation link and it should render that link page in  react.&lt;br&gt;
if anyone know please tell me..&lt;/p&gt;

&lt;p&gt;edit :-&lt;/p&gt;

&lt;p&gt;so here is my problem which im asking for help&lt;/p&gt;

&lt;p&gt;assume i have basic react app code here like some routes..&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//app.jsx
import from "./components/MainHomePage"
import from "./components/About"
import from "./components/Contact"

import {
  createBrowserRouter,
  createRoutesFromElements,
  Route,
  RouterProvider,
} from "react-router-dom";

const router = createBrowserRouter(
  createRoutesFromElements(
    &amp;lt;Route path="/" element={&amp;lt;RootLayout /&amp;gt;}&amp;gt;
      &amp;lt;Route index element={&amp;lt;Navbar /&amp;gt;} /&amp;gt;
      &amp;lt;Route index element={&amp;lt;MainHomePage /&amp;gt;} /&amp;gt;
      &amp;lt;Route path="about" element={&amp;lt;About /&amp;gt;} /&amp;gt;
      &amp;lt;Route path="contact" element={&amp;lt;Contact /&amp;gt;} /&amp;gt;
      &amp;lt;Route path="blog" element={&amp;lt;Blog /&amp;gt;} /&amp;gt;
    &amp;lt;/Route&amp;gt;
  )
);

ReactDOM.createRoot(document.getElementById("root")).render(
  &amp;lt;React.StrictMode&amp;gt;
    &amp;lt;RouterProvider router={router} /&amp;gt;
  &amp;lt;/React.StrictMode&amp;gt;
);

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

&lt;/div&gt;



&lt;p&gt;assume i have some content written in each route page&lt;br&gt;
now look into my navbar component&lt;br&gt;
&lt;/p&gt;

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

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

const [text, setText] = useState('')

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

const handleSubmit = (e) =&amp;gt; {
       e.preventDefault() //prevent default page refresh behavior
       setText('') //to empty input box
}
return (
    &amp;lt;nav&amp;gt;
       &amp;lt;ul className="navbar-links"&amp;gt;
         &amp;lt;li&amp;gt; 
            &amp;lt;Link to={"/"}&amp;gt; Home &amp;lt;/Link&amp;gt;
         &amp;lt;/li&amp;gt;
         &amp;lt;li&amp;gt; 
            &amp;lt;Link to={"/contact"}&amp;gt; Contact &amp;lt;/Link&amp;gt;
         &amp;lt;/li&amp;gt;
         &amp;lt;li&amp;gt; 
            &amp;lt;Link to={"/about"}&amp;gt; About &amp;lt;/Link&amp;gt;
         &amp;lt;/li&amp;gt;
         &amp;lt;li&amp;gt; 
            &amp;lt;Link to={"/blog"}&amp;gt; Blog &amp;lt;/Link&amp;gt;
         &amp;lt;/li&amp;gt;
       &amp;lt;/ul&amp;gt;

       &amp;lt;div className="navbar-search-box"&amp;gt;
         &amp;lt;form onSubmit={handleSubmit}&amp;gt;
             &amp;lt;input type="text" value={text} onChange={handleChange}&amp;gt;
             &amp;lt;button type="submit"&amp;gt; Search &amp;lt;/button&amp;gt; 
         &amp;lt;/form&amp;gt;
       &amp;lt;/div&amp;gt;
    &amp;lt;/nav&amp;gt;
)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;here is my root layout component&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//RootLayout.jsx

import Navbar from "./component/Navbar"
import {Outlet} from "react-router-dom"

const RootLayout = () =&amp;gt; {
    return(
     &amp;lt;&amp;gt;
       &amp;lt;Navbar /&amp;gt;
       &amp;lt;Outlet /&amp;gt;
     &amp;lt;/&amp;gt;
)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;so now i want to do when i type in the search  input box and when i click on search button it will set state to that text and render result page or any particular result but when click to any other navlink from navbar my result page whatever we searched it is not changing the state to empty and my new page whichever we clicked from navbar is not rendering becuase of state, it is a bug so how do i solve this after searching and when i want to navigate to other navbar pages i want to remove result page and state should be empty and render new route page..&lt;/p&gt;

&lt;p&gt;i hope i explained ...&lt;/p&gt;

</description>
      <category>react</category>
      <category>help</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Question :--</title>
      <dc:creator>ivadam00</dc:creator>
      <pubDate>Tue, 27 Sep 2022 04:25:31 +0000</pubDate>
      <link>https://dev.to/ivadam00/question--71e</link>
      <guid>https://dev.to/ivadam00/question--71e</guid>
      <description>&lt;p&gt;How to take dependent select box option value using javaScript and and do something with it and show it in html document.&lt;/p&gt;

&lt;p&gt;im beginner in web development :(&lt;/p&gt;

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