<?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: Atefeh  Mohammaddoust</title>
    <description>The latest articles on DEV Community by Atefeh  Mohammaddoust (@thisisatefe).</description>
    <link>https://dev.to/thisisatefe</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%2F584872%2F5f2e9ea4-4867-4fa5-a9bb-ec1864774704.jpeg</url>
      <title>DEV Community: Atefeh  Mohammaddoust</title>
      <link>https://dev.to/thisisatefe</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thisisatefe"/>
    <language>en</language>
    <item>
      <title>Implementing a dark theme toggle with react-redux</title>
      <dc:creator>Atefeh  Mohammaddoust</dc:creator>
      <pubDate>Tue, 12 Jul 2022 16:01:17 +0000</pubDate>
      <link>https://dev.to/thisisatefe/implementing-a-dark-theme-toggle-with-react-redux-1fpp</link>
      <guid>https://dev.to/thisisatefe/implementing-a-dark-theme-toggle-with-react-redux-1fpp</guid>
      <description>&lt;h2&gt;
  
  
  Implementing a dark theme toggle with react-redux
&lt;/h2&gt;

&lt;p&gt;It’s been a few years since dark mode became a popular feature of many websites, so I decided to write about how to implement it using react-redux. All code from this tutorial is available in &lt;a href="https://github.com/atefeh-dev/dark-theme"&gt;this repository,&lt;/a&gt; And Here’s what we will build:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_jkEPsuM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/3604/1%2A8h6o3Gv_XWgpl2MbrOsoRA.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_jkEPsuM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/3604/1%2A8h6o3Gv_XWgpl2MbrOsoRA.gif" alt="" width="880" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Logic
&lt;/h2&gt;

&lt;p&gt;We have a switch button that has two states: Sun and Moon. Sun Icon is for the light theme, while Moon Icon is for the dark theme. in this project, Redux solved a lot of problems for you, you could easily access data throughout the entire app without having to pass it through each component. Not only could you read this data, but you could also manipulate the state from anywhere in the app as well. and we have a config file that I define the theme properties for LIGHT and DARK themes, such as textColor, backgroundColor, borderColor, and so on. I also attached my basic theme objects for those two themes.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note&lt;/em&gt;&lt;/strong&gt;: &lt;em&gt;you should use redux when You have a very large and complex app with multiple states that are needed in many places of the app and You have often refreshing states.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;The Project Setup&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;I usually use yarn because it is a fast, reliable, and secure alternative to NPM. There are three things we need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;an actual store to hold the state&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;an action to dispatch intent&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;a reducer to handle that intent&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;an action type&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s easy enough:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
About Action You can think of an action as an event that describes something that happened in the application. here the action is changeTheme.&lt;br&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
I Always handle any manipulate in Reduce section.&lt;br&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
I use to keep action types separately because, In this way, you reduce the risk of accidentally misspelling one or more of the action types in one of the sources where they’re used. This will also prevent wasting a lot of time debugging a simple bug.&lt;br&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h3&gt;
  
  
  Now, to provide a theme
&lt;/h3&gt;

&lt;p&gt;We need to tell our component(s) how to style themselves based on the current theme.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&amp;gt;  NOTE : Remember that you must define variables in both classes, even if they are the same.

&lt;h2&gt;
  
  
  Let’s toggle
&lt;/h2&gt;

&lt;p&gt;Great! Now all that is left, is to dispatch the changeTheme action whenever the icon is clicked.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
Let’s take a closer look, we use the useSelector hook to get state from our store using a selector function.

&lt;p&gt;All done!&lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;br&gt;
this post is already on &lt;a href="https://atefe-dev.medium.com/implementing-a-dark-theme-toggle-with-react-redux-14ec197cbff7"&gt;https://atefe-dev.medium.com/implementing-a-dark-theme-toggle-with-react-redux-14ec197cbff7&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Create a show/hide password toggle button in Reactjs.</title>
      <dc:creator>Atefeh  Mohammaddoust</dc:creator>
      <pubDate>Fri, 08 Jul 2022 17:25:21 +0000</pubDate>
      <link>https://dev.to/thisisatefe/create-a-showhide-password-toggle-button-in-reactjs-1oi8</link>
      <guid>https://dev.to/thisisatefe/create-a-showhide-password-toggle-button-in-reactjs-1oi8</guid>
      <description>&lt;h2&gt;
  
  
  Create a show/hide password toggle button in Reactjs.
&lt;/h2&gt;

&lt;p&gt;Hey, if you’re looking to find out how to create a show/hide password toggle like this, I’m going to show you how you can do it in four steps. The idea is to change the type of input from text to password, then password to text when you click the label.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VH3K6fBj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2APKIYxHmzwmzrZuFzb-VgGw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VH3K6fBj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2APKIYxHmzwmzrZuFzb-VgGw.gif" alt="show/hide toggle password" width="600" height="93"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1
&lt;/h2&gt;

&lt;p&gt;Let’s start by creating an input tag with a password as the type of input.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  Step 2
&lt;/h2&gt;

&lt;p&gt;Use the useState() react hook to determine if the password in the input field should be shown, using a boolean state called passwordShown.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
As a first step, let’s give the initial boolean state value of false, as we don’t want the password input field to appear when the user tries to enter the password. Users should only see them when they click on the Show Password button.
&lt;h2&gt;
  
  
  Step 3
&lt;/h2&gt;

&lt;p&gt;By now, instead of hardcoding the password in the input tag, we need to make it dynamic, so that if the passwordShown boolean state is true, the password will be shown, and if it is false, the password will not be shown.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  Step 4
&lt;/h2&gt;

&lt;p&gt;Now, Let’s attach an onClick handler to a tag so that when the user clicks the link it should display the password.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
 In step3, I explain to you how to make the link text dynamic instead of hard-coded.

&lt;p&gt;That’s all! 😃. We have made a working Show/Hide password toggle. Thanks for reading! &lt;br&gt;
you can also read this article on medium &lt;a href="https://atefe-dev.medium.com/create-a-show-hide-password-toggle-button-in-reactjs-68b6b840e31b"&gt;https://atefe-dev.medium.com/create-a-show-hide-password-toggle-button-in-reactjs-68b6b840e31b&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Creating Protected Routes With React Router V6</title>
      <dc:creator>Atefeh  Mohammaddoust</dc:creator>
      <pubDate>Fri, 01 Jul 2022 10:21:31 +0000</pubDate>
      <link>https://dev.to/thisisatefe/creating-protected-routes-with-react-router-v6-3l5a</link>
      <guid>https://dev.to/thisisatefe/creating-protected-routes-with-react-router-v6-3l5a</guid>
      <description>&lt;p&gt;Hey, if you’re looking to find out how to create a Private Route in Reactjs, I’m going to show you how you can do it in only 2 steps. This approach is actually very clean and makes our component much simpler.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The idea is that a user must first meet certain requirements to access that route. In this case, the dashboard page can only be accessed by logged-in users&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Step 1
&lt;/h2&gt;

&lt;p&gt;Let’s start by creating a Component, and we call it . we can pass in more than one route inside of this component. The  allows the Users component to render its child routes.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  Step 2
&lt;/h2&gt;

&lt;p&gt;we would simply pass in  to a , and then nest all the components that we want to be private inside of this route.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;that’s it 😄, Any developer who is looking forward to learning React or even the ones who have been using React for a while should be able to use and enjoy the stuff in this article!! 😄&lt;/p&gt;

&lt;p&gt;The article has also been published in &lt;a href="https://atefe-dev.medium.com/creating-protected-routes-with-react-router-v6-95498195128b"&gt;https://atefe-dev.medium.com/creating-protected-routes-with-react-router-v6-95498195128b&lt;/a&gt;&lt;/p&gt;

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