<?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: coding_tarento</title>
    <description>The latest articles on DEV Community by coding_tarento (@coding_tarento).</description>
    <link>https://dev.to/coding_tarento</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%2F756387%2F2fbeed36-4341-462f-9a91-1d90c4ef740a.png</url>
      <title>DEV Community: coding_tarento</title>
      <link>https://dev.to/coding_tarento</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/coding_tarento"/>
    <language>en</language>
    <item>
      <title>Custom Select Input with React</title>
      <dc:creator>coding_tarento</dc:creator>
      <pubDate>Fri, 19 Aug 2022 10:42:00 +0000</pubDate>
      <link>https://dev.to/coding_tarento/how-to-use-select-input-inside-react-component-4e6m</link>
      <guid>https://dev.to/coding_tarento/how-to-use-select-input-inside-react-component-4e6m</guid>
      <description>&lt;p&gt;Hi aliens 👽, I am here to share most simplest pattern for select input. If you are struggling with select input 😥,confused and facing difficulties to use pure html select input , then this blog is for you my dear. In this blog we are going to discuss controlled input without using any third party library.&lt;br&gt;
lets jump into the code...💻&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// App.js
import "./styles.css";
import Dropdown from "./Dropdown";
import { useState } from "react";
export default function App() {
  const [selected, setSelected] = useState("Choose One");
  return (
    &amp;lt;div className="App"&amp;gt;
      {/* custom dropdown menu */}
      &amp;lt;Dropdown selected={selected} setSelected={setSelected} /&amp;gt;
      {selected}
    &amp;lt;/div&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;// Dropdown.js
import { useState } from "react";
function Dropdown({ selected, setSelected }) {
  const [isActive, setIsActive] = useState(false);
  const options = ["React", "Vue", "Angular"];
  return (
    &amp;lt;div className="dropdown"&amp;gt;
      &amp;lt;div className="dropdown-btn" onClick={(e) =&amp;gt; setIsActive(!isActive)}&amp;gt;
        {selected}
        &amp;lt;span className="fas fa-caret-down"&amp;gt;&amp;lt;/span&amp;gt;
      &amp;lt;/div&amp;gt;
      {isActive &amp;amp;&amp;amp; (
        &amp;lt;div className="dropdown-content"&amp;gt;
          {options.map((option) =&amp;gt; (
            &amp;lt;div
              onClick={(e) =&amp;gt; {
                setSelected(option);
                setIsActive(false);
              }}
              className="dropdown-item"&amp;gt;
            {option}
            &amp;lt;/div&amp;gt;
          ))}

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

    &amp;lt;/div&amp;gt;
  );
}
export default Dropdown;

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

&lt;/div&gt;



&lt;p&gt;Here we are lopping through options array for option tag.&lt;br&gt;
This is fully controlled component  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;We have create the isActive state for updating the option display if it is false , options will hide , and if it is true we are rendering option , this is simple conditional rendering .&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;then after we are using onChange event for targeting option value &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;onChnage we are capturing event , and we are setting event.target.value to selected state &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;woah ! finish yep so simple to create your own custom controlled select input , hope you like the information , you can also check sandbox link and play around it!😺&lt;br&gt;
&lt;a href="https://codesandbox.io/s/custom-dropdown-select-oyisxm"&gt;https://codesandbox.io/s/custom-dropdown-select-oyisxm&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>useState ()</title>
      <dc:creator>coding_tarento</dc:creator>
      <pubDate>Thu, 14 Jul 2022 14:14:00 +0000</pubDate>
      <link>https://dev.to/coding_tarento/usestate--1mmh</link>
      <guid>https://dev.to/coding_tarento/usestate--1mmh</guid>
      <description>&lt;p&gt;Hi👋, if you landed up on this page there is good chance that you already know the JavaScript .I believe if you reading this blog that mean you have basic understanding of variables . if your answer is yes then congratulations ! you will understand useState very easily .&lt;br&gt;&lt;br&gt;
   lets think about it , what is the purpose of variable?? yep yep yep you are absolutely right ! , the puspose of  variable is store some value and we can change the value of variable .finally react talks ...&lt;br&gt;
&lt;strong&gt;important note&lt;/strong&gt; useState hook is only for functional component&lt;/p&gt;

&lt;p&gt;useState accepts an initial state and returns two values&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The current state.&lt;/li&gt;
&lt;li&gt;A function that updates the state.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To use the useState Hook, we first need to import it into our component.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;import {useState} from "react"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;sample counter using useSate hook:&lt;br&gt;
&lt;code&gt;import {useState} from "react"&lt;br&gt;
import "./styles.css";&lt;br&gt;
export default function App() {&lt;br&gt;
// count is state name and setCount is a setter function &lt;br&gt;
const [count,setCount]=useState(0)&lt;br&gt;
 const addHandler =()=&amp;gt;{&lt;br&gt;
  setCount(count+1)&lt;br&gt;
}&lt;br&gt;
const substractHandler=()=&amp;gt;{&lt;br&gt;
  setCount(count-1)&lt;br&gt;
} &lt;br&gt;
  return (&lt;br&gt;
   &amp;lt;div&amp;gt;&lt;br&gt;
      &amp;lt;div className="heading-name"&amp;gt;&lt;br&gt;
      Counter App&lt;br&gt;
      &amp;lt;/div&amp;gt;&lt;br&gt;
      &amp;lt;div className="count"&amp;gt;&lt;br&gt;
        {count}&lt;br&gt;
       &amp;lt;/div&amp;gt;&lt;br&gt;
      &amp;lt;div className="button-container"&amp;gt;&lt;br&gt;
       &amp;lt;button class="counter-button" onClick={addHandler}&amp;gt; + &lt;br&gt;
      &amp;lt;/button&amp;gt;&lt;br&gt;
       &amp;lt;button class="counter-button" onClick={substractHandler}&amp;gt; &lt;br&gt;
     - &amp;lt;/button&amp;gt;&lt;br&gt;
      &amp;lt;/div&amp;gt;&lt;br&gt;
    &amp;lt;/div&amp;gt;)}&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
we can able to change the state value by using setter function easily . The count is the current value and setCount is setter function for manipulating count value . &lt;br&gt;
summery : &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;react hooks are special functions 

&lt;ol&gt;
&lt;li&gt;useState is also a special kind of function which accepts 
state as an argument it can be anything string, array , object , 
number &lt;/li&gt;
&lt;li&gt;it will return current value and setter  function.
Hope you love the blog! you can check the sandbox link and play around it.. take carea!!!
&lt;a href="https://codesandbox.io/s/react-uesstate-hook-counter-mvki7w?file=/src/App.js:0-595"&gt;https://codesandbox.io/s/react-uesstate-hook-counter-mvki7w?file=/src/App.js:0-595&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;


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

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